Results 1 to 3 of 3

Math Help - Matlab-help needed

  1. #1
    Newbie
    Joined
    Dec 2008
    Posts
    5

    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?
    Thanks in advanced.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Rorshach View Post
    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?
    Thanks in advanced.
    Plot them each in a different graphics window switching from window to window with "figure(idx)" where idx is the index for the next figure

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Dec 2008
    Posts
    5

    !

    God bless your soul, you are a good man that deserves a long and happy life.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Some help in matlab needed please
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 5th 2010, 10:01 AM
  2. More matlab help needed please
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 4th 2010, 06:33 AM
  3. Matlab Help needed
    Posted in the Math Software Forum
    Replies: 1
    Last Post: September 1st 2009, 08:33 PM
  4. Help needed to perform bootstrap with matlab
    Posted in the Math Software Forum
    Replies: 5
    Last Post: March 6th 2009, 03:22 AM
  5. MATLAB - matrice help needed
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 11th 2008, 05:01 AM

Search Tags


/mathhelpforum @mathhelpforum