How to fix error of this type: "Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue"

조회 수: 3 (최근 30일)
I am trying to solve a system of nonlinear equations with fsolve command. The function script is:
function F = eqn1(z)
z(6) = 0.01:0.01:0.01;
F(1) = z(1) + z(2) + z(3) -1;
F(2) = z(4) + z(5) + z(6) -1;
F(3) = z(1).*(10.^((1.167.*(z(2)).^2 +0.8085.*z(2).*z(3))./((z(1)+1.168.*z(2)+z(3)).^2))) - z(4).*(10.^((1.167.*(z(5)).^2 +0.8085.*z(5).*z(6))./((z(4)+1.168.*z(5)+z(6)).^2)));
F(4) = z(2).*(10.^((1.733.*(z(1)).^2 +0.383.*z(1).*z(3)+0.046.*(z(3)).^2)./((z(2)+0.856.*z(1)+z(3)).^2)) - z(5).*(10.^((1.733.*(z(4)).^2 +0.383.*z(4).*z(6)+0.046.*(z(6)).^2))./((z(5)+0.856.*z(4)+z(6)).^2)));
F(5) = z(3).*(10.^((2.019.*(z(2)).^2 -0.4252.*z(2).z(1))./((1.168.*z(2)+3.5215.*z(1)+z(3)).^2))) - z(6).*(10.^((2.019.*(z(5)).^2 -0.4252.*z(5).*z(4))./((1.168.*z(5)+3.5215.*z(4)+z(6)).^2)));
end
And the call to fsolve is:
fun = @eqn1;
z0 = [1 0 0 0 1];
z = fsolve(fun,z0)
but its showing
Error in eqn2_solver (line 3)
z = fsolve(fun,z0)
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
How can I fix this?? Thanks!!

답변 (1개)

Alex Sha
Alex Sha 2019년 5월 24일
Hi,“z(2).z(1)” should be "z(2).*z(1)"

카테고리

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