Fitting differential equations using function file, error message "too many input arguments"

2 ビュー (過去 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

採用された回答

Torsten
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 件)

カテゴリ

Help Center および File ExchangeSystems of Nonlinear Equations についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by