Fitting differential equations using function file, error message "too many input arguments"
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Torsten
am 22 Aug. 2022
Bearbeitet: Torsten
am 22 Aug. 2022
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Systems of Nonlinear Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!