Too many input arguments - Fminsearch
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Good morning guys,
I have been stuck with fminsearch for over a day, as I keep getting too many input arguments error for all the times I try to apply the equation.
I am really stuck and any help would be severely appreciated.
Best regards,
Pedro
function fmin
clear all %começar limpando a memória
x0=0; %parâmetro de valor inicial para a condição
options=optimset('Display','iter','TolFun',0.1)
[x]=fminsearch(@f,x0,options);
function fx=f(x)
fx=2*x^2-5*x+6;
2 commentaires
madhan ravi
le 20 Mar 2019
Modifié(e) : madhan ravi
le 20 Mar 2019
Remove clear all, add two end at the end of your code.
Good morning Madhan,
I tried it but there was not change. I keep getting the following message:
[x]=fminsearch(@f,x0,options);
Error using fminsearch
Too many input arguments.
>> which fminsearch -all % what do you get?
/Applications/MATLAB_R2018b.app/toolbox/matlab/optimfun/fminsearch.p
/Applications/MATLAB_R2018b.app/toolbox/matlab/optimfun/fminsearch.m % Shadowed
>>
If you see more than 2 files then you may have created your own function named as fminsearch.m , please verify it and get back with the results.
Also try the below:
which f -all
which fmin -all
Hey Madhan, I have tried fiddling with everything:
That is what I got. Apparently the files are all right, and there is not any hiccups on the fminsearch when I look through its files.
>> which fminsearch -all
C:\Program Files\MATLAB\R2018a\toolbox\matlab\optimfun\fminsearch.p
C:\Program Files\MATLAB\R2018a\toolbox\matlab\optimfun\fminsearch.m % Shadowed
>>
>> which f -all
'f' not found.
>> which fmin -all
'fmin' not found.
>> disp(Answer)
Sorry, out of ideas
Stephen23
le 20 Mar 2019
Modifié(e) : Stephen23
le 20 Mar 2019
>> which f -all
'f' not found.
>> which fmin -all
'fmin' not found.
- Do you know what the MATLAB Search Path is, and how to check it?
- Did you save the files on the MATLAB Search Path, or in the current directory?
- Did you save both functions in the same Mfile, or in two files?
- What are the file names of those Mfile/s?
- Are those two functions the only things saved in those Mfile/s?
- Have you added any third-party toolboxees that might change the Search Path?
- What is your Current Directory?
Réponses (1)
Torsten
le 19 Mar 2019
function fmin
x0=0; %parâmetro de valor inicial para a condição
options=optimset('Display','iter','TolFun',0.1)
[x]=fminsearch(@f,x0,options)
end
function fx=f(x)
fx=2*x^2-5*x+6;
end
Save the code as fmin.m and load it into MATLAB. For me, it worked without problems.
5 commentaires
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!