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 commentaires

Ameer Hamza
Ameer Hamza le 1 Avr 2020
Which MATLAB release are you using?
Jens Turowski
Jens Turowski le 1 Avr 2020
Matlab R2019b, institutional licence with all toolboxes.
Ameer Hamza
Ameer Hamza le 1 Avr 2020
Modifié(e) : Ameer Hamza le 1 Avr 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.
Here you go:
function options = prepareOptionsForSolver(options, solverName)
%
%PREPAREOPTIONSFORSOLVER Prepare options for solver
%
% OPTIONS = PREPAREOPTIONSFORSOLVER(OPTIONS,
% SOLVERNAME) performs tasks to ensure the options are set up for use by
% the solver. The following tasks are performed:-
%
% * If a user has passed a SolverOptions object, first ensure that it is
% a set of options for fseminf.
%
% * If a user has passed a SolverOptions object, now extract the options
% structure from the object.
% Copyright 2012-2018 The MathWorks, Inc.
% If a user has passed a structure, we cannot tell whether a user wrote the
% code that passes the structure before or after 16a. In this case, we
% assume that the code was written before 16a and set TolFunValue to
% TolFun, if TolFunValue is not in options. We also convert any string
% data types to character arrays.

Connectez-vous pour commenter.

 Réponse acceptée

Jens Turowski
Jens Turowski le 1 Avr 2020

0 votes

Thanks, found a copy of a 2016 release fsolve function in one of the local folders. Thanks for your time and effort. :o) Jens

2 commentaires

Ameer Hamza
Ameer Hamza le 1 Avr 2020
Glad to be of help.
John D'Errico
John D'Errico le 1 Avr 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.

Connectez-vous pour commenter.

Plus de réponses (1)

Ameer Hamza
Ameer Hamza le 1 Avr 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 commentaires

Jens Turowski
Jens Turowski le 1 Avr 2020
Thanks for the answer, but this cannot be the case. I installed Matlab on this computer yesterday and it the first project I am doing with the new installation. I definately have not changed any of the functions.
Can you show the output of
which fsolve

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by