Results 1 to 2 of 2

Math Help - ode45 help

  1. #1
    Newbie
    Joined
    May 2010
    Posts
    1

    ode45 help

    Hey,

    I am trying to get the following equations working:

    Here is what I am using to call the differential equations:

    function [t,y]=callersixequs(timelength,S_0,E_0,I_0,R_0,Ip_0,Rp_ 0,r,rp,a,ap,b)

    %This is the caller in order to solve the differential equations

    [t,y] = ode45(@(t,y) sixequs(t,y,r,rp,a,ap,b),[0 timelength],[S_0,E_0,I_0,R_0,Ip_0,Rp_0]);

    plot(t,y(:,1),t,y(:,2),t,y(:,3))


    Here is the function for my differential equations (it's in a separate file):

    function dy = sixequs(t,y,r,rp,a,ap,b)

    y = zeros(6,1);
    dy = zeros(6,1);



    dy(1) = -r*y(1)*y(3)- rp*y(1)*y(5);

    dy(2) = r*y(1)*y(3)-b*y(2);

    dy(3) = b*y(2)-a*y(3);

    dy(4) = a*y(3);

    dy(5) = rp*y(1)*y(5)-ap*y(5);

    dy(6) = ap*y(5);


    I need to figure out why this is not working. Assignment due Friday!


    I am using the following caller since these are the parameters I have gotten from a paper:
    [t,y]=callersixequs(55,6.3E6,100,50,0,0.5E6,0,10.19E-8,7.079E-8,0.47,0.461,0.103)

    Do you think you couuld help me figure out why this isn't working? I'm getting all constant values for my values for the solution.

    Thanks
    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 awesome123 View Post
    Hey,

    I am trying to get the following equations working:

    Here is what I am using to call the differential equations:

    function [t,y]=callersixequs(timelength,S_0,E_0,I_0,R_0,Ip_0,Rp_ 0,r,rp,a,ap,b)

    %This is the caller in order to solve the differential equations

    [t,y] = ode45(@(t,y) sixequs(t,y,r,rp,a,ap,b),[0 timelength],[S_0,E_0,I_0,R_0,Ip_0,Rp_0]);

    plot(t,y(:,1),t,y(:,2),t,y(:,3))


    Here is the function for my differential equations (it's in a separate file):

    function dy = sixequs(t,y,r,rp,a,ap,b)

    y = zeros(6,1);
    dy = zeros(6,1);



    dy(1) = -r*y(1)*y(3)- rp*y(1)*y(5);

    dy(2) = r*y(1)*y(3)-b*y(2);

    dy(3) = b*y(2)-a*y(3);

    dy(4) = a*y(3);

    dy(5) = rp*y(1)*y(5)-ap*y(5);

    dy(6) = ap*y(5);


    I need to figure out why this is not working. Assignment due Friday!


    I am using the following caller since these are the parameters I have gotten from a paper:
    [t,y]=callersixequs(55,6.3E6,100,50,0,0.5E6,0,10.19E-8,7.079E-8,0.47,0.461,0.103)

    Do you think you couuld help me figure out why this isn't working? I'm getting all constant values for my values for the solution.

    Thanks
    Code:
    function dy = sixequs(t,y,r,rp,a,ap,b)
    y = zeros(6,1);  % that's your problem
    dy = zeros(6,1);
     
    dy(1) = -r*y(1)*y(3)- rp*y(1)*y(5);
    dy(2) = r*y(1)*y(3)-b*y(2);
    dy(3) = b*y(2)-a*y(3);
    dy(4) = a*y(3);
    dy(5) = rp*y(1)*y(5)-ap*y(5);
    dy(6) = ap*y(5);
    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Ode45
    Posted in the Math Software Forum
    Replies: 5
    Last Post: October 28th 2009, 06:40 PM
  2. Matlab ode45
    Posted in the Math Software Forum
    Replies: 8
    Last Post: October 24th 2009, 12:22 PM
  3. Using ODE45
    Posted in the Math Software Forum
    Replies: 10
    Last Post: March 29th 2009, 02:14 PM
  4. ode45
    Posted in the Differential Equations Forum
    Replies: 3
    Last Post: March 19th 2009, 05:58 AM
  5. ode45 MATLAB
    Posted in the Math Software Forum
    Replies: 2
    Last Post: September 24th 2008, 05:02 AM

Search Tags


/mathhelpforum @mathhelpforum