Info
此问题已关闭。 请重新打开它进行编辑或回答。
How do I create a loop to plot two graphs in each figure ?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!