Plot multiple figures from the for loop in the same plot
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
KSSV
on 19 May 2016
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.
More Answers (0)
See Also
Categories
Find more on Annotations 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!