csvデータを複数重ねてグラフ化し、値によって色分けする方法について
Show older comments
度々質問させて頂いています。
現在csvデータを複数重ねてグラフ化しております。
具体的には
list = dir('*.csv');
figure
hold on
for ii = 1:length(list)
a = readmatrix(list(ii).name);
A = a.*1e6;
plot(A(1,:),'b');
end
上記コードで添付のfigure1のグラフが出来ます。
X軸の単位は「ms」、Y軸の単位は「μV」です。
次にY軸の値に応じてグラフの色分けを試みました。
Y軸の値で(最大値)-(最小値) < 100 μVになる波形だけを赤にしようとし、
関数peak2peakを使用しました。
(例:最大値+50μV、最小値-30μV→80μV)
list = dir('*.csv');
figure
hold on
for ii = 1:length(list)
a = readmatrix(list(ii).name);
A = a.*1e6;
if peak2peak(A) < 100;
color = 'red';
else
color = 'blue';
end
plot(A(1,:),color);
end
上記コードでグラフ化すると、添付のfigure2にようになりました。
figure2をみると、(最大値)-(最小値) < 100 μV が赤になっているわけではなさそうです。
以下を教授頂きたいです。
①peak2peakの使い方がおかしいでしょうか。他の関数が適しているでしょうか。
②また、X軸0ms~300msの範囲内でなどと、X軸の範囲を指定する条件を追加することなどは可能でしょうか。
ご検討頂けると幸いです。
宜しくお願い致します。
Accepted Answer
More Answers (0)
Categories
Find more on Networks 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!