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