MATLAB: How to avoid the negative results from nlinfit function

negativenlinfit

How can I avoid the negative results from the nlinfit function? Some articles advice to use lsqcurvefit but how and where, I don't understand?
thankx a lot

Best Answer

LSQCURVEFIT allow you to specify upper and lower bounds on the parameters via the ub and lb input arguments. I can't tell if NLINFIT lets you do the same. You could also try a transformation of your parameters that ensures positivity, i.e., instead of making your model a function of a parameter x, make it a function of x=z^2 and fit with respect to z.
Related Question