fminsearch returns Not enough input arguments.

48 views (last 30 days)
Hi I have defined a function objfun as follows.
% function z = objfun(x)
Then I tried to find its minimum (I know it is (0,0) ... I just want to do some tricks on top of this function) by using the following
% x = fminsearch(objfun,[2,2])
and got the following error
Not enough input arguments.
Error in objfun (line 3)
Error in try1 (line 3)
x = fminsearch(objfun,[2,2])
Could anyone help me with this please? Thank you!

Accepted Answer

Walter Roberson
Walter Roberson on 16 Apr 2016
x = fminsearch(@objfun,[2,2])
  1 Comment
Minghao Luo
Minghao Luo on 9 Mar 2020
Edited: Minghao Luo on 9 Mar 2020
I have met this annoying problem as well. I am very grateful your answer helped me solve it.
BTW I found you almost answered every question on this forum about fminsearch 'Not enough input arguments'. What a nice guy you are

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!