I’ve looked at many other posts but I still cannot find the error in my code.
Here is my ode system
function dYdt = ydot(t, y, g, r, q, b, d)
dYdt = [r*(1-b*g)*y(2)*(1-q*y(2)) - g*y(1) - d*y(1);
g*y(1) - d*y(2)];
end
Here is when I try to use it with ode45:
% parameters
r = 1.1079;
b = 0.2535;
d = 0.0814;
q = 1;
tspan = [0 100];
% simulate ode
[t,y] = ode45(@(t,y) ydot(t, y, 0.3, r, q, b, d), tspan, [0.5;0.5]);
which results in this error message. I’m not sure where I’m going wrong, I’ve written dozens of ode files and passed them into ode45, this is the first time I’m ever getting this error. I have tried to rewrite it and what not, I either get ‘too many input arguments’ or ‘not enough input arguments’. I’m lost.
Error using @(t,y)ydot(t,y,g,r,q,b,d)
Too many input arguments.
Error in @(t,y)ydot(t,y,g,r,q,b,d)
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 104)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);