readmatrixで任意のファイルを指定してcsvを読み込みグラフを作成する方法を知りたいです。
Ältere Kommentare anzeigen
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のデータ置かれているフォルダを開いてグラフ化したいデータを選ぶようにするにはどうしたらよいのでしようか。
Akzeptierte Antwort
Weitere Antworten (1)
Hernia Baby
am 9 Jul. 2022
Bearbeitet: Hernia Baby
am 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
Kategorien
Mehr zu スプレッドシート finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!