Fitting differential equations using function file, error message "too many input arguments"
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello,
I am attempting to fit the set of differential equations outlined in the code below to the data given by Gut, Intestine, and MLN. Upon attempting to run this code however, I am presented with the message of having "too many input arguments." I am unsure of how to fix this issue, as it seems that all input arguments of the ModelIntegrationFunction are accounted for.
function Fit = ModelIntegrationFunction
function C=kinetics(theta,t)
%c0 denotes the intial conditions of each compartment
c0=[(10^7);0;0];
[T,Cv]=ode45(@DifEq,t,c0);
function dC=DifEq(t,c)
dcdt=zeros(3,1);
dcdt(1)= -7.2132*c(1);
dcdt(2)= 0.4832*c(1)+0.863*c(2)*(1-(c(2)/(10^8)))-((4.9*c(3))/(1+c(2)*(10^(-3.35))))-298*c(2);
dcdt(3)= 298*c(2)+2.82*c(3)-0.48*c(3);
dC=dcdt;
end
C=Cv;
end
t = [0,0.5,1,2];
Gut = [1;2;3;4]; %No data inputted, doesnt matter
Intestine = [0;24920000;33820000;54779900];
MLN = [0;4.165;868.261;5929.337];
c = [Gut, Intestine, MLN];
theta0=[1;1];
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c);
fprintf(1,'\tRate Constants:\n')
for k1 = 1:length(theta)
fprintf(1, '\t\tTheta(%d) = %8.5f\n', k1, theta(k1))
end
tv = linspace(min(t), max(t));
Fit = kinetics(theta, tv);
end
댓글 수: 0
채택된 답변
Torsten
2022년 8월 22일
편집: Torsten
2022년 8월 22일
Runtime is too long, but seems to work in R2022 a.
t = [0,0.5,1,2];
Gut = [1;2;3;4]; %No data inputted, doesnt matter
Intestine = [0;24920000;33820000;54779900];
MLN = [0;4.165;868.261;5929.337];
c = [Gut, Intestine, MLN];
theta0=[1;1];
[theta,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat]=lsqcurvefit(@kinetics,theta0,t,c);
fprintf(1,'\tRate Constants:\n')
for k1 = 1:length(theta)
fprintf(1, '\t\tTheta(%d) = %8.5f\n', k1, theta(k1))
end
tv = linspace(min(t), max(t));
Fit = kinetics(theta, tv);
function C=kinetics(theta,t)
%c0 denotes the intial conditions of each compartment
c0=[(10^7);0;0];
[T,Cv]=ode45(@DifEq,t,c0);
function dC=DifEq(t,c)
dcdt=zeros(3,1);
dcdt(1)= -7.2132*c(1);
dcdt(2)= 0.4832*c(1)+0.863*c(2)*(1-(c(2)/(10^8)))-((4.9*c(3))/(1+c(2)*(10^(-3.35))))-298*c(2);
dcdt(3)= 298*c(2)+2.82*c(3)-0.48*c(3);
dC=dcdt;
end
C=Cv;
end
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!