fsolve function working at times but failing sometimes! Warning on non-square systems!

Hello, Would somebody please explain to me why is that I sometimes get the following warning:
" Trust-region-dogleg algorithm of FSOLVE cannot handle non-square systems; using Levenberg-Marquardt algorithm instead. "
I get an answer many other times without getting this warning, but 'sometimes' I get NaN as an answer along with this warning! This is while the code is exactly the same each time.
I am solving two non-linear equations in my program each time. This warning is related to fsolve function I use for solving those equations. Why is that this function sometimes fails but works the other times without any change in the code?!?
I would be grateful if somebody explain this to me as it makes my program very unreliable.
Thank you. Atekeh

6 commentaires

Is it possible you sometimes have more than 2 unknown variables?
Hi, No! It's always two unknown variables to be solved and the other input parameters to the MATLAB function (where fsolve is called) are always the same! Thanks.
Matt J
Matt J le 13 Nov 2013
Modifié(e) : Matt J le 13 Nov 2013
Don't think so. If fsolve thinks you have a non-square system, you have different numbers of equations from variables at some point.
Not that of I know! I swear I have only two equations in my code. That's weird! And as I said, most of the time it runs and there is no such error/warning and I get the answer! How is that the same code, with the same set of parameters passed to it, runs but fails sometimes?! Thanks anyway.
Without seeing your code, we cannot know. Maybe you have rand()-driven lines somewhere...
Oh the code is so long and nested that is not easy to look at. No, I don't have rand() function in my code. I appreciate your efforts to help though. Thanks.

Connectez-vous pour commenter.

Réponses (0)

Tags

Question posée :

le 12 Nov 2013

Commenté :

le 13 Nov 2013

Community Treasure Hunt

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

Start Hunting!

Translated by