I'd like help with the ode45 function for a biological model

I'm trying to solve a differential equation using the ode45 model however I am encountering a recurring error problem here is my script:
function dydt = odepharm(t,y,S,R)
dydt = zeros(2,1);
dydt(1) = (gs*(Nmax-(y(1)+y(2))/Nmax)-ks*c/c+EC50s)*y(1);%S;
dydt(2) = (gr*(Nmax-(y(1)+y(2))/Nmax)-kr*c/c+EC50r)*y(2);%R;
end
gs=0.99;
gr=0.66;
Nmax=1.10e9;
ks=1.56;
kr=1.17;
c=400;
EC50s=0.21;
EC50r=5.19;
tspan = [0:12:96];
y0 = [1.06 1.06];
[t,y] = ode45(@(t,y) odefpharm(t,y,S,R), tspan, y0);
The error message includes:
Unrecognized function or variable 'S'.
Error in @(t,y)odefpharm(t,y,S,R)
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);

 Accepted Answer

Try if you are expecting this result for
tspan = [0 96];
y0 = [1.06 1.06];
[t, y] = ode15s(@odepharm, tspan, y0);
plot(t, y(:,1)), grid on, xlabel('t'), ylabel('y_{1}')
function dydt = odepharm(t,y)
dydt = zeros(2,1);
gs = 0.99;
gr = 0.66;
Nmax = 1.10e9;
ks = 1.56;
kr = 1.17;
c = 400;
EC50s = 0.21;
EC50r = 5.19;
dydt(1) = (gs*(Nmax - (y(1) + y(2))/Nmax) - ks*c/c + EC50s)*y(1); % S;
dydt(2) = (gr*(Nmax - (y(1) + y(2))/Nmax) - kr*c/c + EC50r)*y(2); % R;
end

More Answers (0)

Products

Release

R2022b

Tags

Asked:

on 25 Jul 2023

Answered:

on 25 Jul 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!