MATLAB: Failure in initial objective function evaluation. FMINCON cannot continue. (Not enough input arguments)

fmincon

Hi,
I am finding what is probably a very silly problem with fmincon.
I am performing a numerical deconvolution with the lucy-richardson algorithm (deconvlucy). I initially deconvolve a numerical function (an experimental peak, not an analytical form) and a "synthetic" gaussian function that I generate. To verify the deconvolution, I convolve the result back with the gaussian and compare the results to the original function. I have created an error function that performs all the computations and gives me the squared differences.
deconvlucy has a number of variables that can be tweaked to improve the quality of the results. Now, in order to tweak the variables of the algorithm I just need to use fmincon with my function as objective function. One small detail is that my function (DeconvolutionError) takes four arguments but only two of them relate to the deconvolution algorithm and need to be optimized while the other two remain fixed, so I need to pass these last two to the function as parameters. Easy enough (or so I thought) with an anonymous function.
This is the code:
FWHM=0.005;
step=0.0001;
%These are the two variables that will remain fixed
AnonymousFunction=@(iterations,filter) DeconvolutionError(FWHM,step,iterations,filter);
%This is the anonymous function in which I use the two fixed values of FWHM and step and leave the other two variables free.
%It calls DeconvolutionError, which resides in a different .m file
IterationsInitialValue=20;
FilterInitialValue=0.5;
InitialValues=[IterationsInitialValue,FilterInitialValue];
%Initial values of the variables to be minimezed by fmincon
LowerBounds=[1,0.0];
UpperBounds=[50,1.0];
%Upper and lower bounds for the two variables
OptimumValues=fmincon(AnonymousFunction,InitialValues,[],[],[],[],LowerBounds,UpperBounds);
The code fails with the message in the title. I know that DeconvolutionError works fine (standalone) and that AnonymousFunction also does (I can evaluate it passing it two arguments at any point in the code after its creation). This probably is something related to how I pass the values to fmincon, since it complains about not enough input arguments, but for the life of me I cannot find the problem.
Any help will be gratly appreciated!.

Best Answer

The objective functions for the optimization routines take only one input, that being the parameter vector. You can pass other arguments to ‘AnonymousFunction’, however fmincon (here) can pass only one argument to it.