fsolve returns non-integer exitflag

조회 수: 6 (최근 30일)
Corrado
Corrado 2014년 3월 7일
댓글: Corrado 2014년 3월 7일
Hi everyone,
I am experiencing a strange problem. For as far as I know an exitflag should always be an integer (identifying the reason the algorithm terminated). However when solving my problem with fsolve, the exitflag turns out to be a non-integer: 1.329410886565489.
fsolve did not find a solution, but that is perfectly possible. The exitflag being a non-integer value on the other hand seems really strange to me.
What could be the problem?
Kind regards, Corrado Sirianni
  댓글 수: 5
Matt J
Matt J 2014년 3월 7일
편집: Matt J 2014년 3월 7일
Can you at least show your call to FSOLVE, and maybe a bit of the surrounding code like the set-up of the initial x0 and the selection of options using OPTIMSET or OPTIMOPTIONS?
Corrado
Corrado 2014년 3월 7일
for iso_GAMMA = 2
dlmwrite('Prho_coordinates_iso_gamma.dat',[iso_GAMMA iso_GAMMA],'delimiter',' ','newline','pc','-append')
for teta = -1:0.01:1
[r,exitflag] = fsolve(@fun_iso_gamma,0.01)
if r > 0.0585
continue
end
if r < 0
continue
end
. . . . . . etc. etc.

댓글을 달려면 로그인하십시오.

채택된 답변

Alan Weiss
Alan Weiss 2014년 3월 7일
I guess that you are interpreting the output of fsolve incorrectly. As stated in the function reference page, the outputs of fsolve are, in this order:
[x,fval,exitflag,output,jacobian] = fsolve(...)
exitflag is always the third output. I would bet that the third output that you obtain from solve is an integer, whatever name you give it.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
Corrado
Corrado 2014년 3월 7일
You are totally right! I forgot the order is also of importance! Thank you very much Alan!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by