Hello I am trying to to solve a big system of ode's using ode45 but can't seem to get thecode right. Can anybody spot the error? Here is the code I have:
function phago_dynamics % This will run the time dynamics of activation and deactivation of the % various involved in phagocytosis. tspan = [0 10]; yzero = [1; 1; 1/2; 0; 1; 1/2; 0; 1; 1/2; 0; 1; 1/2; 0; 1; 1/2; 0; 1;... 1/2; 0; 1; 1/2; 0; 1; 1/2; 0; 1; 1/2; 0; 1; 1/2; 0; 1; 0; 0; 0; 2; 0; 0; 0; 1; 0];
k1=1; k2=1; k3=1; k4=1; k5=1; k6=1; k7=1; k8=1; k9=1; k10=1; k11=1; k12=0.2; k13=1; k14=1; k15=1; k17=1; k18=1; k19=1; k20=1; k21=1; k22=1; k23=1; k24=1; k25=1; k26=1; k27=1; k28=1; k29=1; k30=1; k31=1; k32=1; k33=1; k34=1; k35=1; k36=1; k37=1; k38=1; k39=1; k40=1; k41=1; k42=1; k43=1; k44=1; k45=1; k46=1; k47=1; k48=1; k49=1; k50=1; k51=1; k52=1; k53=1; k54=1; k55=1; k56=1; k57=1;
[t,y] = ode45(@phagocytosis,tspan,yzero);
plot(y(:,1), y(:,2))
%--------------Nested functions-----------------------------------------
function yprime = phagocytosis(y)
%Phagocytosis system, parametrized.
yprime = [0; -k1*y(2)+k2*y(3); k1*y(2)-k2*y(3)-k3*y(1)*y(3) -
k4*y(41)*y(3)+k5*y(4); k(3)*y(1)*y(3)+k4*y(41)*y(3)-k5*y(4);
...
-k6*y(5)+k7*y(6); k6*y(5)-k7*y(6)-k8*y(1)*y(6)+k9*y(7);
k8*y(1)*y(6)-k9*y(7); -k10*y(8)+k11*y(9)+k12*y(16)*y(10); ...
k10*y(8)-k11*y(9)-k13*y(4)*y(9); k13*y(4)*y(9)-
k12*y(16)*y(10); -k14*y(11)+k15*y(12)+k16*y(19)*y(13); ...
k14*y(11)-k15*y(12)-k17*y(7)*y(12); k17*y(7)*y(12)-
k16*y(19)*y(13); -k18*y(14)+k19*y(15); k18*y(14)-k19*y(15)-
k20*y(38)*y(15)+k21*y(16); ...
k20*y(38)*y(15)-k21*y(16); -k22*y(17)+k23*y(18); k22*y(17)-
k23*y(18)-k24*y(38)*y(18)+k25*y(19); k24*y(38)*y(18)-
k25*y(19);...
-k26*y(20)+k27*y(21); k26*y(20)-k27*y(21)-k28*y(1)*y(21)-
k29*y(13)*y(21)+k30*y(21); k28*y(1)*y(21) + k29*y(13)*y(21)-
k30*y(22);...
-k31*y(23)+k32*y(24); k31*y(23)-k32*y(24)-
k33*y(1)*y(24)+k34*y(25); k33*y(1)*y(24)-k34*y(25); -
k35*y(26)+k36*y(27); ...
k35*y(26)-k36*y(27)-k37*y(1)*y(27)-k38*y(38)*y(27)+k39*y(28);
k37*y(1)*y(27)+k38*y(38)*y(27)-k39*y(28);...
-k40*y(29)+k41*y(30); k40*y(29)-k41*y(30)-k42*y(10)*y(30)-
k43*y(13)*y(30)+k44*y(31); k42*y(10)*y(30)+k43*y(13)*y(30)-
k44*y(31);...
-k45*y(32)+k46*y(33); k45*y(32)-k46*y(33)-
k47*y(36)*y(33)+k48*y(34); k47*y(36)*y(33)-k49*y(34)*y(13)-
k48*y(34)+k50*y(35);...
k49*y(34)*y(13)-k50*y(35); k51*y(31)-k52*y(28)*y(36)-
k53*y(22)*y(36)-k47*y(36)*y(33)+k48*y(34);
k54*y(25)*y(38);...
k53*y(22)*y(36)-k54*y(25)*y(38); k55*y(28)*y(36); -
k56*y(35)*y(40)+k57*y(41)];
end
end
When I run the code I get the following error:
Error using phago_dynamics/phagocytosis Too many input arguments.
Error in odearguments (line 87) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115) odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in phago_dynamics (line 14) [t,y] = ode45(@phagocytosis,tspan,yzero);
Any comments would be greatly appreciated. P.S. The code is actually all in the one file. For some reason the system is only reading the second part as matlab code.

回答(1 个)

The ‘Too many input arguments’ error comes from the ODE functions requiring both the independent and dependent variables as inputs, even if you don’t use the independent variable in your code.
You need to define it as:
function yprime = phagocytosis(t,y)
You also need more continuation operators ‘...’ and to define all your ‘k’ parameters. I will defer to you sort those problems.

类别

标签

Community Treasure Hunt

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

Start Hunting!

Translated by