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 .

采纳的回答

KSSV
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 CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by