# Thread: Matlab-help needed

1. ## Matlab-help needed

Hey,
I have been trying( for the last several hours...) to make this horrid thing work(you don't have to read the whole script, the main point is the several loops and the plot):
I(1)=10^2;
II(1)=10^2;
III(1)=10^2;
IV(1)=10^2;
c=4;
s=0.5;
for k=1:2:9
T=0.1*k;
for j=1:2:9
f=0.1*j;
for h=1:5
M=0.5+0.5*h;
N(1)=4*10^2;
for i=1:20
I(i+1)=s*c*(2/(N(i)-1))*(I(i)*((1-T)*((N(i)-1)/2*c)+I(i)-1+(f/2)*II(i)+III(i)/2+(f/4)*IV(i)+M*T*(2*(I(i)-1)+f*II(i)+III(i)/2+f/4*IV(i)))+(f/4)*II(i)*III(i)*(1+M*T));
II(i+1)=s*c*(2/(N(i)-1))*(II(i)*((1-T)*((N(i)-1)/2*c)+(f/2)*I(i)+(f^2)*(II(i)-1)+(f/4)*III(i)+(f^2/2)*IV(i)+M*T*(2*(f^2)*(II(i)-1)+f*I(i)+(f/4)*III(i)+f^2/2*IV(i)))+f/4*I(i)*IV(i)*(1+M*T));
III(i+1)=s*c*(2/(N(i)-1))*(III(i)*(((N(i)-1)/2*c)+(1/2)*I(i)+(f/4)*II(i)+III(i)-1+(f/2)*IV(i)+M*T*((1/2)*I(i)+(f/4)*II(i)))+(f/4)*I(i)*IV(i)*(1+M*T));
IV(i+1)=s*c*(2/(N(i)-1))*(II(i)*(((N(i)-1)/2*c)+(f/4)*I(i)+(f^2/2)*(II(i))+(f/2)*III(i)+(f^2)*(IV(i)-1)+M*T*((f^2/2)*(II(i))+(f/4)*I(i)))+f/4*II(i)*III(i)*(1+M*T));
N(i+1)=I(i+1)+II(i+1)+III(i+1)+IV(i+1);
end
x=(1:i+1);
plot(x,I,x,II,x,III,x,IV);
end
end
end

The thing is that I am trying to some how save all of the plots so I can view them later. But since they are inside a loop,and there's a whole lot of them, simple thing like 'subplot' will not do.
Anyone knows how do I solve this issue?

2. Originally Posted by Rorshach Hey,
I have been trying( for the last several hours...) to make this horrid thing work(you don't have to read the whole script, the main point is the several loops and the plot):
I(1)=10^2;
II(1)=10^2;
III(1)=10^2;
IV(1)=10^2;
c=4;
s=0.5;
for k=1:2:9
T=0.1*k;
for j=1:2:9
f=0.1*j;
for h=1:5
M=0.5+0.5*h;
N(1)=4*10^2;
for i=1:20
I(i+1)=s*c*(2/(N(i)-1))*(I(i)*((1-T)*((N(i)-1)/2*c)+I(i)-1+(f/2)*II(i)+III(i)/2+(f/4)*IV(i)+M*T*(2*(I(i)-1)+f*II(i)+III(i)/2+f/4*IV(i)))+(f/4)*II(i)*III(i)*(1+M*T));
II(i+1)=s*c*(2/(N(i)-1))*(II(i)*((1-T)*((N(i)-1)/2*c)+(f/2)*I(i)+(f^2)*(II(i)-1)+(f/4)*III(i)+(f^2/2)*IV(i)+M*T*(2*(f^2)*(II(i)-1)+f*I(i)+(f/4)*III(i)+f^2/2*IV(i)))+f/4*I(i)*IV(i)*(1+M*T));
III(i+1)=s*c*(2/(N(i)-1))*(III(i)*(((N(i)-1)/2*c)+(1/2)*I(i)+(f/4)*II(i)+III(i)-1+(f/2)*IV(i)+M*T*((1/2)*I(i)+(f/4)*II(i)))+(f/4)*I(i)*IV(i)*(1+M*T));
IV(i+1)=s*c*(2/(N(i)-1))*(II(i)*(((N(i)-1)/2*c)+(f/4)*I(i)+(f^2/2)*(II(i))+(f/2)*III(i)+(f^2)*(IV(i)-1)+M*T*((f^2/2)*(II(i))+(f/4)*I(i)))+f/4*II(i)*III(i)*(1+M*T));
N(i+1)=I(i+1)+II(i+1)+III(i+1)+IV(i+1);
end
x=(1:i+1);
plot(x,I,x,II,x,III,x,IV);
end
end
end

The thing is that I am trying to some how save all of the plots so I can view them later. But since they are inside a loop,and there's a whole lot of them, simple thing like 'subplot' will not do.
Anyone knows how do I solve this issue?
matlabhelp, needed 