Solve system of non-linear equations with parameter in for loop

2 ビュー (過去 30 日間)
Maria Lepouri
Maria Lepouri 2018 年 11 月 21 日
コメント済み: Maria Lepouri 2018 年 11 月 22 日
Hello! I am trying to solve a system of nonlinear equations,but for these equations i have a paramater (D) that takes values from 0 to 0.5, and i try to solve the system in afor loop for each D value.
D=0:0.01:0.5;
for i= 1:length(D)
options=optimset('Display','off');
fsol = fsolve(@solutionsproblem,D(i),options)
X(i) = fsol(1)
end
function F=solutionsproblem(x,D)
mm=0.5;
k=0.1;
ktonos=1;
y=0.3;
a=0.2;
sf=2;
F(1)=D-((mm*x(2)*x(1))/(k+x(2))*(1+(x(3)/ktonos)));
F(2)=-D*x(3)+((a*mm*x(2)*x(1))/(k+x(2))*(1+(x(3)/ktonos)));
F(3)=D*(sf-x(2))-(1/y)*((mm*x(2)*x(1))/(k+x(2))*(1+(x(3)/ktonos)));
end
It keeps telling me the following:
Not enough input arguments.
Error in solutionshit (line 10)
F(1)=D-((mm*x(2)*x(1))/(k+x(2))*(1+(x(3)/ktonos)));
Error in fsolve (line 242)
fuser = feval(funfcn{3},x,varargin{:});
Error in ask13pavlou (line 5)
fsol = fsolve(@solutionshit,D(i),options)
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
What am I missing here? Thanks a lot beforehand!

採用された回答

Matt J
Matt J 2018 年 11 月 21 日
編集済み: Matt J 2018 年 11 月 21 日
It should look something like,
D=0:0.01:0.5;
x0=...
options=optimset('Display','off');
X(i)=nan(1,length(D));
for i= 1:length(D)
fsol = fsolve(@(x) solutionsproblem(x,D(i)), x0, options);
X(i) = fsol(1);
end

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by