Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How do I create a loop to plot two graphs in each figure ?

조회 수: 1 (최근 30일)
Luiz Felippe
Luiz Felippe 2013년 4월 1일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi,
I'm trying to plot this on two different figures with a loop:
x=[5:8];
y=cell(1,4);
y{1}=[1:4];
y{2}=[-x.^2];
y{3}=[(x.^3)./2];
y{4}=[8,8,8,8];
figure(1)
subplot(2,1,1)
plot(x,y{1})
hold on
figure(1)
subplot(2,1,2)
plot(x,y{2})
hold on
figure(2)
subplot(2,1,1)
plot(x,y{3})
hold on
figure(2)
subplot(2,1,2)
plot(x,y{4})
I tryed make something like that:
x=[5:8];
y=cell(1,4);
y{1}=[1:4];
y{2}=[-x.^2];
y{3}=[(x.^3)./2];
y{4}=[8,8,8,8];
for num=1:4
for pos=1:2
subplot(2,1,pos)
if num<=2
for num=pos
hold on
figure(1)
plot(x,y{num})
end
else
hold on
figure(2)
plot(x,y{num})
end
end
end
But this is not exactly what I want. If I had more "y" and the same x-axis.For example y{5},y{6},y{7},...How do I create a loop to plot two graphs in each figure ?.
So,for example,if I had ten "y" (y{1} to y{10}) and the same x-axis.The number of figures will be five with two graphs in each figure.
Thanks

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by