Passing back extra values through fsolve
3 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
Walter Roberson
2012 年 7 月 6 日
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!