2012-07-04 26 views
1

我想在lsqcurvefit命令中使用Levenberg Marquardt算法。我已经做了以下内容:使用lsqcurvefit中的选项

options = optimset('LevenbergMarquardt','on'); 
x = lsqcurvefit(@myfun,x0,xdata,ydata,options); 

我得到以下错误:

??? 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] = ...

如何克服这个问题?

回答

2

您应该查看功能lsqcurvefitdocumentation。您使用的功能错误。要通过options你应该使用7参数版本并通过结构作为最后7论点的结构:

x = lsqcurvefit(@myfun,x0,xdata,ydata,lb,ub,options); 

这意味着你还需要定义lbub为第五和第六的说法。这些是x中设计变量的下限和上限。

但你也可以通过空矩阵如果不存在界限:

x = lsqcurvefit(@myfun,x0,xdata,ydata,[],[],options);