I want to use Levenberg Marquardt Algorithm in the lsqcurvefit command. I’ve done the following :
options = optimset('LevenbergMarquardt','on');
x = lsqcurvefit(@myfun,x0,xdata,ydata,options);
I get the following error:
??? Error using ==> optim\private\lsqncommon
LSQCURVEFIT only accepts inputs of data type double.Error in ==> lsqcurvefit at 149
[x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...
How do I overcome this error?
You should take a look at the documentation for the function
lsqcurvefit. You are using the function wrong. To pass the structoptionsyou should use the 7-argument version and pass the struct as the last 7th argument:This means that you also need to define
lbandubas the 5th and 6th argument. These are the lower and upper bounds for the design variable inx.But you can also pass empty matrices if no bounds exist: