How to change the stop criteria of fsolve?

141 次查看(过去 30 天)
I have a set of nonlinear equations and I am solving them by fsolve. x(1) to x(6) are my unknowns to be determined and X, Y, Z are definite constants. I wrote the following function:
======
function z=equ_set(x)
global X Y Z
z(1)=x(4)-x(5)*x(6)/x(1)-X(1);
z(2)=x(2)-x(6)^2/x(1)-X(2);
z(3)=x(3)-x(5)^2/x(1)-X(3);
z(4)=x(1)-x(6)^2/x(2)-Y(1);
z(5)=x(5)-x(4)*x(6)/x(2)-Y(2);
z(6)=x(3)-x(4)^2/x(2)-Y(3);
z(7)=x(1)-x(5)^2/x(3)-Z(1);
z(8)=x(2)-x(4)^2/x(3)-Z(2);
z(9)=x(6)-x(4)*x(5)/x(3)-Z(3);
end
====== and wrote the followings in command line to solve the eqs. set:
global X Y Z
X=[2/3, 5/3, 2/3];
Y=[5/2, 1/2, 1/2];
Z=[2, 1, 0];
x0=[1,1,1,1,1,1];
fsolve(@equ_set,x0)
=======
Since fsolve is a numeric solver I used it. How can I change the stop criteria of fsolve? (for example error<1e-3) I have seen "relative norm(grad r)" but I am not sure whether this is the case and how to change it. Thanks

回答(2 个)

Matt J
Matt J 2014-9-7
There is some reading to be done
You can also implement your own stopping criteria using the OutputFcn option

Star Strider
Star Strider 2014-9-7
If you want to change the default behaviour of fsolve, use the optimoptions function. See the fsolve Options sections for details on what you can change, the 'MaxFunEvals', 'MaxIter', 'TolFun', and 'TolX' possibly being the most relevant for your purposes.

类别

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