Results 1 to 6 of 6

Math Help - Matlab to solve first order differential equation

  1. #1
    Newbie
    Joined
    Jun 2008
    Posts
    4

    Matlab to solve first order differential equation

    Hello all,
    I am a newbie to Matlab.
    I want to solve the first order differential equation.
    I have 6 equations.
    p10'(t)=p10(t)(-M1+M1(t10+t11)+M1*t11)+P20(t)(M1*t10)+P01(t)(M2*t2 1)+p21(t)(M2*t20)
    p20'(t)= .....
    .....
    .....
    ....
    .....
    my teacher told me that at the end of solving , p10+p20+p....+...+..+..=1 and i have to plot that i get "1".
    could anyone help me how to write ?
    Thanks a lot.
    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 azin.kaf304 View Post
    Hello all,
    I am a newbie to Matlab.
    I want to solve the first order differential equation.
    I have 6 equations.
    p10'(t)=p10(t)(-M1+M1(t10+t11)+M1*t11)+P20(t)(M1*t10)+P01(t)(M2*t2 1)+p21(t)(M2*t20)
    p20'(t)= .....
    .....
    .....
    ....
    .....
    my teacher told me that at the end of solving , p10+p20+p....+...+..+..=1 and i have to plot that i get "1".
    could anyone help me how to write ?
    Thanks a lot.
    The way you have expressed this is not clear. In the fragment you give what are variables and what are constants.

    RonL
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jun 2008
    Posts
    4
    Thanks for your reply.

    p10'(t)=p10(t)(-M1+M1(t10+t11)+M1*t11)+P20(t)(M1*t10)+P01(t)(M2*t2 1)+p21(t)(M2*t20)

    In this equation , constants are M1,M2,t10,t11,t21,t20.
    let's say M1=1,M2=2,t10=0.1,t11=0.2,t21=0.1....
    and the initial value of p10(t),p20(t),p....... are 1,0,0,0,0,0. Example, p10(t)=1,p20(t)=0,p...

    If you something still not clear, i always glad to wirte here since i very need to solve this .
    I am waiting for your reply.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    First have you read the help files on the ODE solvers?

    Also see here particularly section 8.

    RonL
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Jun 2008
    Posts
    4
    my first function program

    xxxxxxxxxxxxxxxxx
    function dp = mine(t,p)
    M1=1;M2=2;t10=0.1;t11=0.1;t12=0.1;t111=0.1;t112=0. 01;
    t122=0.02;t20=0.12;t21=0.11;t22=0.006;t211=0.099;t 212=0.11;t222=0.125;
    dp = zeros(6,1); % a column vector
    %dp(1)=P10
    dp(1)=(p(1)*(-M1+(M1*(t10+t11))+(M1*t11)))+(p(3)*(M1*t10))+(p(4) *(M2*t21))+(p(5)*(M2*t20));
    %dp(2)=P1,0+1
    dp(2)=(p(2)*(-M1+(M1*t11)+(M1*(t111+t11))+(M1*(t112+t11))+(M1*(t 122+t11))))+(p(1)*(M1*t112))+(p(3)*(M1*t12))+(p(4) *(M2*t212));
    %dp(3)=P1+1,0
    dp(3)=(p(3)*(-M1+(M1*t11)+(M1*(t111+t11))+(M1*(t112+t11))+(M1*(t 122+t11))))+(p(1)*(M1*t111))+(p(4)*(M2*t22))+(p(5) *(M2*t21));
    %dp(4)=P01
    dp(4)=(p(4)*(-M2+(M2*(t20+t22))+(M2*t22)))+(p(1)*(M1*t12))+(p(2) *(M1*t10))+(p(6)*(M2*t20));
    %dp(5)=P0+1,1
    dp(5)=(p(5)*(-M2+(M2*t22)+(M2*(t211+t22))+(M2*(t212+t22))+(M2*(t 222+t22))))+(p(1)*(M1*t122))+(p(6)*(M2*t21));
    %dp(6)=P0,1+1
    dp(6)=(p(6)*(-M2+(M2*t22)+(M2*(t211+t22))+(M2*(t212+t22))+(M2*(t 222+t22))))+(p(2)*(M1*t12))+(p(4)*(M2*t222));
    %dp = dp( ;
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx

    Main program

    t0=0;
    tf=10;
    x0 = [1 0 0 0 0 0]
    [X,Y]=ode45(@mine,[t0,tf],x0);
    %plot(T,P(:,1),'-',T,P(:,2),'-',T,P(:,3),'-',T,P(:,4),'-',T,P(:,5),'-',T,P(:,6),'-')
    plot(X,Y)

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx

    I want to know the value of p10,p01,1+1,0,..... 6 variables.
    and I want to get p10+p01+..+..+..+..=1.
    so i can prove with plot about we get 1 for sum of 6 variables.
    please help me Sir.
    Thanks a lot.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Jun 2008
    Posts
    4
    Could anyone help me any idea for my problem?
    I am waiting ..
    Last edited by azin.kaf304; June 28th 2008 at 07:06 AM.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Solve second order differential equation by Laplace transform
    Posted in the Differential Equations Forum
    Replies: 3
    Last Post: October 11th 2011, 04:48 PM
  2. Help me to solve a second order differential equation.
    Posted in the Differential Equations Forum
    Replies: 2
    Last Post: March 1st 2011, 11:24 AM
  3. how do i solve this second order differential equation?
    Posted in the Differential Equations Forum
    Replies: 1
    Last Post: May 8th 2010, 05:41 AM
  4. MATLAB Second order nonlinear differential equation
    Posted in the Math Software Forum
    Replies: 2
    Last Post: December 15th 2008, 07:00 PM
  5. Replies: 2
    Last Post: November 25th 2008, 09:29 PM

Search Tags


/mathhelpforum @mathhelpforum