MATLAB: Too many arguments in fminsearch

fminsearch

Hi,
I am trying to use fminsearch to find the minimum of a function with two variables. When running fminsearch I would like to increase the number of function evaluations but whenever I add any options I get an error:
Too many input arguments.
Error in ==> fminsearch at 205
fv(:,1) = funfcn(x,varargin{:});
A simple code to reproduce this would be:
a=@(x)(x(1)^2+5*x(2)^4);
x_min=fminsearch(a,[5,5],'MaxFunEvals',1000);
I am using Matlab R2009b Version 7.9.0
Has anybody encountered this problem before, or am I making a mistake of some sort?
Thank you,
Sven

Best Answer

According to the documentation, fminsearch wants one struct instead of pairs of parameters and values:
Options.MaxFunEvals = 1000;
x_min = fminsearch(a, [5,5], Options)
Or:
Options = optimset('MaxFunEvals', 1000);