Solution for a Subplot in loop reading from multiple columns with an increment and from different excel sheets

1 次查看(过去 30 天)
Hi all,
I am reading a .xlsx file with three sheets. I am trying to subplot x and y from each sheet which are in increments.
Here is the example for subplot (8,3,1)
Example 1: Subplot 1 includes the following data
(x1,y1)=(a(:,1),a(:,2)) % continues with an increment of 3 columns for subplot (8,3,2) and so on.
(x2,y2)=(b(:,1),b(:,2)) % continues with an increment of 3 columns for subplot (8,3,2) and so on.
(x3,y3)=(c(:,1),c(:,2)) % continues with an increment of 3 columns for subplot (8,3,2) and so on.
The following code is just getting them all in a single chart.
a=xlsread('Doc1.xlsx','sheet1');
b=xlsread('Doc1.xlsx','sheet2');
c=xlsread('Doc1.xlsx','sheet3');
x1=a(:,1:3:70);
y1=a(:,2:3:71);
x2=b(:,1:3:70);
y2=b(:,2:3:71);
x3=c(:,1:3:70);
y3=c(:,2:3:71);
figure(1)
plot(x1,y1,x2,y2,x3,y3)
figure(2)
for t1=1:24
subplot(8,3,t1)
plot(x1,y1,x2,y2,x3,y3)
end
figure(2) gives all the sublpots with all the data. Can someone look into this code and suggest me how to overcome this?
Kind regards,
Jagan

采纳的回答

darova
darova 2020-3-24
You don't use for loop index. Use it
  1 个评论
JAGAN MOHAN KUMMARI
Awesome! Thanks mate it worked. I tried soemthing like below. It didnt work.
figure(2)
for t1=1:24
subplot(8,3,t1)
h{t1}=plot(x1(t1,:),y1(t1,:),x2(t1,:),y2(t1,:),x3(t1,:),y3(t1,:))
end
Thanks again!

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by