fsolve returns non-integer exitflag

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 comentarios

Mischa Kim
Mischa Kim el 7 de Mzo. de 2014
Just out of curiosity, could you attach your code?
Corrado
Corrado el 7 de Mzo. de 2014
I would like to, but that's somewhat complicated because it's a really long script (divided over several functions and m-files) leading to the equations to be solved (system of two equations). I'm computing the admissibility domain for expansion shock waves in the near-critical region of methane, carbon dioxide and ethylene.
Corrado
Corrado el 7 de Mzo. de 2014
Editada: Corrado el 7 de Mzo. de 2014
Actually, I have the same problem with any other equations I'm trying to solve with fsolve. The exitflag is never an integer...
Matt J
Matt J el 7 de Mzo. de 2014
Editada: Matt J el 7 de Mzo. de 2014
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?
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.

Iniciar sesión para comentar.

 Respuesta aceptada

Alan Weiss
Alan Weiss el 7 de Mzo. de 2014
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 comentario

Corrado
Corrado el 7 de Mzo. de 2014
You are totally right! I forgot the order is also of importance! Thank you very much Alan!

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 7 de Mzo. de 2014

Comentada:

el 7 de Mzo. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by