readmatrixで任意のファイルを指定してcsvを読み込みグラフを作成する方法を知りたいです。
Show older comments
csvファイルを読み込みグラフを作ろうとしています。
a=readmatrix("sample1.csv");
plot([a(:,1)],[a(:,2)]);
[a(:,1)]は計測されたデータの時間軸で[a(:,2)]はプロットしたいデータになります。
sample1.csvのデータと同じパスにsample2.csv,sample3.csv...と別のデータがあるときに
a=readmatrix("sample2.csv");
plot([a(:,1)],[a(:,2)]);
のようにスクリプトを書き換えることなく、sample2.csvのデータ置かれているフォルダを開いてグラフ化したいデータを選ぶようにするにはどうしたらよいのでしようか。
Accepted Answer
More Answers (1)
Hernia Baby
on 9 Jul 2022
Edited: Hernia Baby
on 9 Jul 2022
こちらが参考になると思います。
------
list = dir('*.csv');
figure
hold on
for ii = 1:length(list)
a = readmatrix(list(ii).name);
plot(a(:,1),a(:,2))
end
Categories
Find more on スプレッドシート in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!