
File Exchange上のコードをMATLAB onlineで用いる
3 views (last 30 days)
Show older comments
どなたかFile Exchange上のコードをMATLAB onlineで用いる方法をご存じないでしょうか。
もしそのような方法があれば、ご教示いただけますと幸いです。
0 Comments
Answers (1)
Kojiro Saito
on 15 May 2023
File Exchangeのコードがどのような形態でダウンロードできるようになっているかによりますが、ダウンロードボタンがあればそのZipファイルリンクを取得できるのでMATLAB Onlineからwebsaveで保存できますし、GitHubのリンクがあれば、!git cloneで取得することができます。
(1) ダウンロードボタンからZipファイルのリンクを取得。

(2) MATLAB OnlineでwebsaveでZipファイルを保存し、unzipで解凍して使えます。
%% ダウンロードリンクを取得する方法
url = "https://jp.mathworks.com/matlabcentral/mlc-downloads/downloads/98ee7702-abae-47b3-975d-419dad136b99/56ba27ee-8040-4c40-90a3-3168f16ad1aa/packages/zip";
% websaveでファイルとして保存
websave("myzip.zip", url)
% zipを解凍
unzip("myzip.zip")
%% ダウンロードしたspider_plotを使ってみます。
% Initialize data points
D1 = [5 3 9 1 2];
D2 = [5 8 7 2 9];
D3 = [8 2 1 4 6];
P = [D1; D2; D3];
% Spider plot
spider_plot(P);
% Legend properties
legend('D1', 'D2', 'D3', 'Location', 'southoutside');
File Exchangeのコードの公開元がGitHubになっている場合は、以下の方法で取得できます。
(3) GitHubのリンクを「GitHub でライセンスを表示」から取得し、MATLAB Onlineのシステムコマンド(!付きのコマンド)でgit cloneを実行します。MATLAB Answers上ではgitが使えないので実行しませんが、MATLAB Onlineでは動作しました。
%% Gitクローンする方法
!git clone https://github.com/NewGuy012/spider_plot
cd spider_plot/
%% ダウンロードしたspider_plotを使ってみます。
% Initialize data points
D1 = [5 3 9 1 2];
D2 = [5 8 7 2 9];
D3 = [8 2 1 4 6];
P = [D1; D2; D3];
% Spider plot
spider_plot(P);
% Legend properties
legend('D1', 'D2', 'D3', 'Location', 'southoutside');
0 Comments
See Also
Categories
Find more on Downloads in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!