Azzera filtri
Azzera filtri

Passing back extra values through fsolve

3 visualizzazioni (ultimi 30 giorni)
Matt
Matt il 5 Lug 2012
Is it possible to pass extra values back through the MATLAB solvers like fsolve? I've read through the documentation but I didn't see anything obvious.
Let me clarify what I'm saying. In my function that evaluates f(x), there are some other values that I can calculate based on the results of the calculations I'm doing to calculate f(x) and I'd like to have access to these values in my main program after fsolve has solved the system because it's annoying to have to go back and essentially redo all the calculations that were done in the last time fsolve called the f(x) function. It also seems like there should be a way around having to recalculate everything
My current work around is using a global variable shared by the main program and the f(x) function and storing the values in the global at the end of the f(x) function, but it seems like something that should be easily doable without a global variable.

Risposte (1)

Walter Roberson
Walter Roberson il 6 Lug 2012
You can optimset an OutputFcn into place. You can use a persistent variable instead of a global, until you see a Done state. But then you have to get the data back somehow, whether by using a global or assignin('base') or guidata() or set() the Userdata field of some handle. fsolve() (like the ode*() routines) have no mechanism for returning upwards a user-defined value.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by