필터 지우기
필터 지우기

Subplots using for loop with varying data increments

조회 수: 9 (최근 30일)
JAGAN MOHAN KUMMARI
JAGAN MOHAN KUMMARI 2020년 4월 27일
댓글: JAGAN MOHAN KUMMARI 2020년 4월 28일
Hi Friends,
I am reading the following data
d=xlsread('data.xlsx','sheet1')
t=d(:,1:4:5);
a=d(:,2:4:6);
v=d(:,3:4:7);
u=d(:,4:4:8);
how can I subplot this data to a 2x3 figures,
1 2 3
4 5 6
figs in Col1: 1:3:4 (1, 4) are with t, and a
figs in Col2: 2:3:5 (2, 5) are with t, and v
figs in Col3: 3:3:6 (3, 6) are with t, and u
Currently, I can plot them individually subplot but worried to making a mistake while creating each subplot in large data. Appreciate any ideas.
Thanks,
Jagan
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 4월 27일
What would be the difference between figure 1 an 4 ?
JAGAN MOHAN KUMMARI
JAGAN MOHAN KUMMARI 2020년 4월 27일
편집: JAGAN MOHAN KUMMARI 2020년 4월 27일
it is like
subplot(2, 3, 1)
plot (d(:,1), d(:,2)) % defined them again as t, a, v, u, which must now be plot (t(:,1),a(:,1))
subplot (2,3,2)
plot(d(:,1),d(:,3))
subplot(2,3,3)
plot(d(:,1),d(:,4))
subplot(2,3,4)
plot(d(:,5),d(:,6))
subplot(2,3,5)
plot(d(:,5),d(:,7))
subplot(2,3,6)
plot(d(:,5),d(:,8))

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 4월 27일
plotvars = {a, v, u};
for K = 1 : 3
subplot(2, 3, K)
plot(t, plotvars{K});
subplot(2, 3, K+3)
plot(t, plotvars{K});
end
  댓글 수: 12
Ameer Hamza
Ameer Hamza 2020년 4월 28일
Similarly, this will also work
y_limits={[-0.5 0.5],[-300 300],[-inf inf]};
JAGAN MOHAN KUMMARI
JAGAN MOHAN KUMMARI 2020년 4월 28일
True, works the same.
Thanks mate!

댓글을 달려면 로그인하십시오.

추가 답변 (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