lsqcurvefit error: Objective function is returning undefined values at initial point. lsqcurvefit cannot continue.
Show older comments
Hello dear all, I am fitting a multiple set of measurements to a function (my non-linear model function) and trying to get the parameters that fit the measurement to the data at best. The model consists of two parameters to be fitted. I have around 4000 measurements (these are actually pixels of images, but irrelevant here...), so I call lsqcurvefit 4000 times. I use the lsqcurvefit with options Levenberg-Marquardt, upper and lower bounded, analytical Jacobian provided by me. I give the lsqcurvefit the same initial point for every measurement (i.e. for each call of the lsqcurvefit). For most of the measurement, the algorithm works and returns me proper values for the parameters. But for some measurements, it gives out the error:
"Objective function is returning undefined values at initial point. lsqcurvefit cannot continue."
I check where the error comes from, it is generated by the built-in matlab function 'snls' called by lsqcurvefit. When I monitor the workings in debug mode and look at the values the function has, it indeed has some 'Inf' values in it, so the error is correctly generated. However, I don't understand why I get 'Inf' for some values of the function, the model function never becomes infinity inside the boundaries I provide the lsqcurvefit with. Plus, I always give the same initialization to each call of lsqcurvefit and most of the times it works, sometimes not. Another plus, when I look at the values of the function in the debug mode, I see different values each time, which is wrong, because the model is the same and the initialization is the same, thus the evaluation of the model at the initialization has to yield the exact same result. Any help or comment will be appreciated. Thanks, Kerem
Accepted Answer
More Answers (0)
Categories
Find more on Nonlinear Least Squares (Curve Fitting) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!