How to change the stop criteria of fsolve?
조회 수: 142 (최근 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
댓글 수: 0
답변 (2개)
Matt J
2014년 9월 7일
There is some reading to be done
You can also implement your own stopping criteria using the OutputFcn option
댓글 수: 0
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!