필터 지우기
필터 지우기

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
JAGAN MOHAN KUMMARI 2020년 3월 24일
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개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by