Hi again! I'm still trying to solve a pharmacokinetic in 13 compartiments and fitting my concentration data vs time with the result, I've learned a lot from you all who have helped me to fix my problems with matlab. I started with solving with ode45 a system of 13 differential equations, I made it! After read Monodkinetics and Igor Moura y tryed to run an isqcurvefit with my pharmacokinetic data. I have concentration data vs time from compartiment number 12 and I want to fit them with equations system, and estimate two elimination constants (K(1) and K(2). So far I go here: I have two files First file named odefcn_script4
%
%% K(1)= constante de eliminación en hígado (hepatic clearance)
% K(2)= constante de eliminación plasmática (plasmatic clearance)
t=[5 15 30 60 120 240];c=[11.46 21.24 3.35 4.53 1.73 2.49]; K0 = [1;14];[K,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@odefcn4,K0,t,c);fprintf(1,'\tConstants:\n')for k1 = 1:length(K) fprintf(1, '\t\tK(%d) = %8.5f\n', k1, K(k1))endtv = linspace(min(t), max(t));Cfit = odefcn4(K, tv);figure(1)plot(t, C, 'p')hold onhlp = plot(tv, Cfit);hold offgridxlabel('Time')ylabel('Concentration')legend(hlp, 'C_1(t)', 'C_2(t)', 'C_3(t)', 'C_4(t)','C_5(t)','C_6(t)','C_7(t)','C_8(t)','C_9(t)','C_10(t)','C_11(t)','C_12(t)','C_13(t)','Location','N')
and file two named odefcn4:
% File odefcn4.m
function C=odefcn4(K,t)CLr=0.0441;Pb=4.47176966;Pcer=1.3191;Pcor=3.3789;Pf=7.2458;Ph=6.1711;Phu=1.2509;Pint=3.7487;Plu=5.4719;Pm=2.4497;Pp=2.53282;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;Vp=0.0429;V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Qc*c(12))-((K(2)*c(12))/Vv))/Vv;dcdt(13)=(Qlu*(c(12)-(c(13)/Plu)))/Vlu;dC=dcdt; endC=Cv(:,12);end
I run the first file and i got this error message:
Not enough input arguments.Error in odefcn4/DifEq (line 58)dcdt(12)=((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;Error in odearguments (line 90)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 odefcn4 (line 44)[T,Cv]=ode45(@DifEq,t,c0,CLr,Pb,Pcer,Pcor,Pf,Ph,Phu,Pint,Plu,Pm,Pp,Pr,Qb,Qc,Qcer,Qcor,Qf,Qh,Qha,Qhu,Qint,Qlu,Qm,Qp,Qr,Va,Vb,Vcer,Vcor,Vf,Vh,Vhu,Vint,Vlu,Vm,Vp,Vr,Vv);Error in lsqcurvefit (line 202) initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});Error in odefcn_script4 (line 19)[K,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@odefcn4,K0,t,c);Caused by: Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.Not enough input arguments.Error in odefcn4/DifEq (line 58)dcdt(12)=((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))-((K(2)*c(12))/Vv))/Vv;Error in odearguments (line 90)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 odefcn4 (line 44)[T,Cv]=ode45(@DifEq,t,c0,CLr,Pb,Pcer,Pcor,Pf,Ph,Phu,Pint,Plu,Pm,Pp,Pr,Qb,Qc,Qcer,Qcor,Qf,Qh,Qha,Qhu,Qint,Qlu,Qm,Qp,Qr,Va,Vb,Vcer,Vcor,Vf,Vh,Vhu,Vint,Vlu,Vm,Vp,Vr,Vv);Error in lsqcurvefit (line 202) initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});Caused by: Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
any help would be valuable,
Best Answer