trying to solve two non-linear simultaneous equations but I had an error figuring out my two unknowns (X(1) &x(2)) , can anyone pls help?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
0 Kommentare
Antworten (3)
Star Strider
am 9 Mai 2023
I cannot fun images of code, only code in text format. I can’t even see all of ‘F’.
The problem is the choice of initial conditions for ‘x0’.
Using:
x0 = rand(2,1);
will probably work. At least it won’t throw that same error.
.
0 Kommentare
John D'Errico
am 9 Mai 2023
Bearbeitet: John D'Errico
am 9 Mai 2023
ARGH. Why would you post a picture of your code? And at that, only a partial picture? Even if I try to show why your code fails, I cannot, since I cannot even see the entire function.
It is just as easy to paste in the code itself, as it is to insert a picture. In fact, it is easier. So why would you make it more difficult to get help? So at best, ll I can do is guess at the problem. Fsolve says you have an undefined result. I would postilate it has seen a NaN, and is upset at the idea, since it can do nothing then.
And that suggest the odds are good that your problem is in your starting values. NEVER start an optimizer at the point [0,0]. It can do all sorts of bad things. But here, my bet is the problem is more in that at the point [0,0], your function is itself undefined. It may well be generating NaNs.
My advice when you run an optimization is to first, TEST the function. Try evaluating it at the start point. Does it make sense? If not, then what will the optimizer do? Computers tend to be pretty dumb things. Then, evaluate the objective at another point. Does the objective return a different value? If not, then again you have a problem.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!