Too many input arguments - Fminsearch
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
madhan ravi
2019 年 3 月 20 日
編集済み: madhan ravi
2019 年 3 月 20 日
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
2019 年 3 月 20 日
編集済み: Stephen23
2019 年 3 月 20 日
>> 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?
回答 (1 件)
Torsten
2019 年 3 月 19 日
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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!