0de45 not enough input arguments
Mostrar comentarios más antiguos
I'm new in mathlab and i'm trying to solve a system of 13 differential equations, then i would like to fit some parameteres. The system is a Pharmacokinetic in 13 different organs and I want to plot Concentration in each one (C). I'm trying to solve the system with ode45, I also know this solver only work with 2 arguments. This is my progress so far:
function dCdt = odefcn( t,C,Qf,Pf,Vf,Qp,Pp,Vp,Qhu,Phu,Vhu,Qm,Pm,Vm,Qcor,Pcor,Vcor,Qint,Pint,Vint,Qb,Pb,Vb,Qha,Qh,Ph,vmax,km,Vh,Qr,Pr,CLr,Vr,Qcer,Pcer,Vcer,Qlu,Plu,Vlu,Qc,Va,Vv)
dCdt=zeros(13,1);
dCdt(1)=(Qf*(C(1)-(C(2)/Pf)))/Vf;
dCdt(2)=(Qp*(C(2)-(C(3)/Pp)))/Vp;
dCdt(3)=(Qhu*(C(1)-(C(4)/Phu)))/Vhu;
dCdt(4)=(Qm*(C(1)-(C(5)/Pm)))/Vm;
dCdt(5)=(Qcor*(C(1)-(C(6)/Pcor)))/Vcor;
dCdt(6)=(Qint*(C(1)-(C(7)/Pint)))/Vint;
dCdt(7)=(Qb*(C(1)-(C(8)/Pb)))/Vb;
dCdt(8)=((Qha*C(1))+(Qb*(C(8)/Pb))+(Qint*(C(7)/Pint))-(Qh*(C(9)/Ph))-((vmax*C(9))/(km+C(9))))/Vh;
dCdt(9)=((Qr*(C(1)-(C(10)/Pr)))-(CLr*C(10)))/Vr;
dCdt(10)=(Qcer*(C(1)-(C(11)/Pcer)))/Vcer;
dCdt(11)=(Qlu*(C(12)-(C(13)/Plu)))/Vlu;
dCdt(12)=(Qc*((C(13)/Plu)-C(1)))/Va;
dCdt(13)=((Qf*(C(2)/Pf))+(Qp*(C(3)/Pp))+(Qhu*(C(4)/Phu))+(Qm*(C(5)/Pm))+(Qcor*(C(6)/Pcor))+(Qr*(C(10)/Pr))+(Qcer(C(11)/Pcer))+(Qh(C(9)/Ph))-(Qc*C(12)))/Vv;
CLr=0.0411;
km=61.2800;
Pcer=1.3191;
Pcor=3.3789;
Pf=7.2458;
Ph=6.1711;
Phu=1.2509;
Pint=3.7487;
Plu=5.4719;
Pm=2.4497;
Pr=6.7441;
Qb=0.0017;
Qc=0.0831;
Qcer=0.0017;
Qcor=0.0041;
Qf=0.0058;
Qh=0.0145;
Qha=0.0019;
Qhu=0.0101;
Qint=0.0109;
Qlu=0.0831;
Qm=0.0231;
Qp=0.0048;
Qr=0.0117;
Va=0.0065;
Vb=5.0000e-04;
Vcer=0.0014;
Vcor=8.0000e-04;
Vf=0.0207;
Vh=0.0092;
Vhu=0.0052;
Vint=0.0065;
Vlu=0.0012;
Vm=0.0972;
vmax=1.7900e-04;
Vp=0.0429;
Vr=0.0017;
Vv=0.0129;
tspan = [0 5];
C0 = [0;0;0;0;0;0;0;0;0;0;0;96.8750;0];
[t,C] = ode45(@(t,C) odefcn(t,C,Qf,Pf,Vf,Qp,Pp,Vp,Qhu,Phu,Vhu,Qm,Pm,Vm,Qcor,Pcor,Vcor,Qint,Pint,Vint,Qb,Pb,Vb,Qha,Qh,Ph,vmax,km,Vh,Qr,Pr,CLr,Vr,Qcer,Pcer,Vcer,Qlu,Plu,Vlu,Qc,Va,Vv), tspan, C0);
end
When I run it, mathlab returs this error:
>> odefun
Not enough input arguments.
Error in odefun (line 3)
dCdt(1)=(Qf*(C(1)-(C(2)/Pf)))/Vf;
4 comentarios
James Tursa
el 3 de Jul. de 2018
Editada: James Tursa
el 3 de Jul. de 2018
Is all of this code in one file as you show it? If so, you need to have it set up differently. E.g., you could have one file as your script that calls ode45:
% File odefcn_script.m
CLr=0.0411;
km=61.2800;
:
tspan = [0 5];
C0 = [0;0;0;0;0;0;0;0;0;0;0;96.8750;0];
[t,C] = ode45(@(t,C) odefcn(... etc
And another separate file for the derivative function:
% File odefcn.m
function dCdt = odefcn(... etc
dCdt=zeros(13,1);
dCdt(1)=(Qf*(C(1)-(C(2)/Pf)))/Vf;
:
end
María Elena Bravo-Gómez
el 4 de Jul. de 2018
María Elena Bravo-Gómez
el 4 de Jul. de 2018
Respuestas (0)
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!