Plot multiple figures from the for loop in the same plot
2 ビュー (過去 30 日間)
古いコメントを表示
Hi My data is in 5 sheets in a excel file. I want to plot data from each sheet in the same figure one over the another. But when I do this, it plots only the last sheet data. ??
%%Program to plot all data in one figure
clc
clear all
filename = 'data.xlsx';
sheetnames = { 'Sheet1','Sheet2','Sheet3','Sheet4','Sheet5' };
n = length(sheetnames);
for idx = 1:n
a = xlsread(filename,sheetnames{idx});
j=1:1:length(a);
Time_hr(j) = a(:,1);
Time_min(j) = a(:,2);
Time(j) = Time_hr(j)+ Time_min(j)/60;
freq(j)= a(:,3);
for j=1:1:length(idx)
plot (Time(j),freq(j));
end
end
Someone help me out .
0 件のコメント
採用された回答
KSSV
2016 年 5 月 19 日
figure ;
hold on
for idx = 1:n
a = xlsread(filename,sheetnames{idx});
j=1:1:length(a);
Time_hr(j) = a(:,1);
Time_min(j) = a(:,2);
Time(j) = Time_hr(j)+ Time_min(j)/60;
freq(j)= a(:,3);
for j=1:1:length(idx)
plot (Time(j),freq(j));
end
end
you have to use hold on..to plot multiple curves on the same plot.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!