필터 지우기
필터 지우기

Subplot in a for-loop

조회 수: 12 (최근 30일)
Betty
Betty 2017년 12월 16일
댓글: Betty 2017년 12월 16일
Hi, I have 33 dataset and I'm trying to make a subplot to show the figures.
My code is as below, the figure(1) is as I wish, but my figure(2) is not, as it only shows dataset 16-20. How can I edit it?
Thank you, B.
figure(1);
for i = 1:15
subplot(3,5,i);
plot(eval(['temp' num2str(i)]))
title(['Patient' num2str(i)])
ylabel('Degrees')
xlabel('Epochs')
end
figure(2);
for i = 16:33
subplot(4,5,i);
plot(eval(['temp' num2str(i)]))
title(['Patient' num2str(i)])
ylabel('Degrees')
xlabel('Epochs')
end

채택된 답변

Rik
Rik 2017년 12월 16일
change
subplot(4,5,i);
to
subplot(4,5,i-15);
That way you make sure the indices start at 1 for the second figure as well
  댓글 수: 1
Betty
Betty 2017년 12월 16일
Thank you, it makes sense and it helped!

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

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