MATLAB: Error using sqpInterface Objective function is undefined at initial point.

double inverted pendulumfminconinverted pendulum

while using nmpc example of the inverted pendulum.I am getting this error. I just change model to double pendulum model in pendulumCT.m file. what should I do?
Error using sqpInterface
Objective function is undefined at initial point. Fmincon cannot continue.
Error in fmincon (line 808)
[X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = sqpInterface(funfcn,X,full(A),full(B),full(Aeq),full(Beq), ...
Error in nmpc (line 52)
uopt = fmincon(COSTFUN,uopt,[],[],[],[],LB,UB,CONSFUN,options);

Best Answer

First try evaluating your cost function with your initial guess and see if you can actually get an output. I believe that fmincon expects the output of the cost function to be a real scalar value. Double check that you're not outputting a complex quantity.
Related Question