0de45 not enough input arguments

조회 수: 2 (최근 30일)
María Elena Bravo-Gómez
María Elena Bravo-Gómez 2018년 7월 3일
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
María Elena Bravo-Gómez
María Elena Bravo-Gómez 2018년 7월 4일
Thank you James Tursa, thank you Stephen Cobeldick @Stephen Cobeldick, sorry, I don't know what a recursive function is, i don't know If I called ode45. I'm new in this. @James Tursa, I tryed as you said, I have now two different files, the first one:
%odefcn_script
CLr=0.0441;
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;
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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;
end
I get the same error:
>> odefcn
Not enough input arguments.
Error in odefcn (line 4)
dCdt(1)=(Qf*(C(1)-(C(2)/Pf)))/Vf;
María Elena Bravo-Gómez
María Elena Bravo-Gómez 2018년 7월 4일
@James Tursa, It works!!!!, I ran the odefnc_script and matlab returns a different errors, apparently I didn't define all the variables (there are a lot!), and when i fixed it I got the plot. Thank you very much!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by