# Thread: ode45 help

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

2. Originally Posted by awesome123
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