简体   繁体   中英

levenberg marquardt curve fitting MATLAB with several parameters

I am trying to fit a huge function with four unknown parameter to my data with levenberg-Marquardt least square method in Matlab. I used this command :

[x, resnorm]=lsqcurvefit(@myfun1,[-100:100], xdata, ydata, ...
                         [-inf, -inf, -1.5, -inf], [inf, inf, 1.5, inf], options)

which means I am interested to constrain the third parameter. But I face with this problem:

??? Error using ==> lsqncommon at 102
Levenberg-Marquardt and Gauss-Newton algorithms do not handle bound constraints and trust-region-reflective algorithm
requires at least as many equations as variables; aborting.

Error in ==> lsqcurvefit at 258
[xCurrent,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ...

I think this error shows that my data is small since they are 36 points or maybe there are too many unknown parameters, but I think four unknown parameters for fitting is fine!

so, what do you think ?Does it mean that MATLAB is not able to fit my function to this 36 points data?

I'd appreciate any comments.

According to this http://www.mathworks.co.uk/help/toolbox/optim/ug/lsqcurvefit.html the second argument is the the start values of the parameters that you wish to optimise for. You are passing in

 [-100:100]

which (unless matlab has greatly changed since I last used it) is a vector of 201 parameters and so it would seem that you are asking matlab to optimise over 201 parameters. As @Dan points out in the comment below, you only have 36 data points and so what you are asking is unreasonable . You want to optimise over just 4 params so you should input just 4 start values. You are passing in length 4 vectors for the limit options so you have an inconsistency here.

I would suggest just inputting a vector of 4 start values for your parameters as second argument and see if it generates the outcome you expect.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM