Too many output arguments in fsolve
Show older comments
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
Which MATLAB release are you using?
Jens Turowski
on 1 Apr 2020
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.
Jens Turowski
on 1 Apr 2020
Accepted Answer
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
Jens Turowski
on 1 Apr 2020
Ameer Hamza
on 1 Apr 2020
Can you show the output of
which fsolve
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!