MATLAB: Error occurs when i writing nonlcon and using fmincon

error too many input argumentsfailure in initial user-supplied nonlinear constraint function evaluation. fmincon cannot continue.:fmincongarchMATLABnonlcon

Hi everyone,
when i writing my GARCH(1,1) models of Heston and Nandi(2000), the implementation involves maximising the likelihod function but ensure the stationarity, my code for optimization function fmincon is:
[param,fval,exitflag,output,lambda,grad,hessian]=fmincon(@lml_GARCH_1, param0, [], [], [], [], lb, ub, @stacon, options, spret)
where stacon is the nonlcon function which contains the restriction that beta+alfa*gamma^2<1, where beta, alfa, gamma are parameters i need to estimate by fmincon.
The stacon function is,
function [c,ceq] = stacon(x)
c= [];
ceq= [];
c(1) = x(1)+x(2)*(x(3))^2-1;
c(2) = -x(1)-x(2)*(x(3))^2 ;
end
but after run the fmincon, errors occurs. It says,
Error using stacon Too many input arguments.
Error in fmincon (line 621) [ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
Error in GARCH2016 (line 29) [param,fval,exitflag,output,lambda,grad,hessian]=fmincon(@lml_GARCH_1, param0, [], [], [], [], lb, ub, @stacon, options, spret);
Caused by: Failure in initial user-supplied nonlinear constraint function evaluation. FMINCON cannot continue.
By the way my option is defined as:
options=optimset('TolFun', 1e-10, 'TolX', 1e-10, 'MaxIter',3600, 'LargeScale', 'off', 'MaxFunEvals', 9000, 'Gradobj', 'off', 'DerivativeCheck', 'off', 'Display', 'iter');
I'm not good for coding especially in matlab, strucggled for a couple of days but cannot have the correction. anyone knows anywhere wrong with the code.
many thanks

Best Answer

Read my response in your newsgroup thread.