Too many output arguments in fsolve
4 views (last 30 days)
Show older comments
Jens Turowski
on 1 Apr 2020
Commented: John D'Errico
on 1 Apr 2020
Dear all,
I trying to solve a system of algebraic equations with the fsolve function. I get the following error message, both with my own script and the example script provided with the documentation (SolutionwithNondefaultOptionsExample.m)
Error using prepareOptionsForSolver
Too many output arguments.
Error in fsolve (line 157)
[options, optionFeedback] = prepareOptionsForSolver(options, 'fsolve');
Error in SolutionWithNondefaultOptionsExample (line 32)
x = fsolve(fun,x0,options)
The function prepareOptionsForSolver is not documented, but the input from fsolve seems to correspond to what is required. Since this also arises in an example from the documentation, there should not be any problems with the syntax.
Does anybody know how to fix this problem? Do you know alternatives? I have tried using the vpasolve function, but my equations include the incomplete gamma function that cannot handle symbolics.
Thanks, Jens
4 Comments
Ameer Hamza
on 1 Apr 2020
Edited: Ameer Hamza
on 1 Apr 2020
I am using R2020a so I cannot directly check the issue. Can you run
edit prepareOptionsForSolver
In command window and paste the first line in your comment (function definition) here.
Accepted Answer
Jens Turowski
on 1 Apr 2020
2 Comments
John D'Errico
on 1 Apr 2020
Then please accept the answer by Ameer, which explicitly tells you to look for other functions or scripts named fsolve, however they got there. Note that putting an old copy of a toolbox function in another directory was a bad idea anyway. It will cause problems down the line.
More Answers (1)
Ameer Hamza
on 1 Apr 2020
It appears that you have somehow overwritten the fsolve function provided by MATLAB. This line show
function options = prepareOptionsForSolver(options, solverName)
That prepareOptionsForSolver only gives one output. But In your error message shows that in your fsolve function, there is a line as follow
[options, optionFeedback] = prepareOptionsForSolver(options, 'fsolve');
which does not match the definition of prepareOptionsForSolver. I checked the definition of fsolve in R2020a, and it contains
options = prepareOptionsForSolver(options, 'fsolve');
I recommend first to check if MATLAB is using correct fsolve function by typing
which fsolve
If it points to MATLAB toolbox directory then I recommend to reinstall MATLAB to recover the original definition of fsolve
2 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!