Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
Luiz Felippe
Luiz Felippe am 1 Apr. 2013
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by