필터 지우기
필터 지우기

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

조회 수: 1 (최근 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 CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by