Fitting data using lsqcurvefit

3 views (last 30 days)
Daniel Alejandro Diaz
Daniel Alejandro Diaz on 10 Apr 2023
Dear Community,
I have been trying to fit my data using lsqcurvefit but I have had trouble with the internal limits. Currently I am getting this prompt when I run the system
Can anyone help me with this prompt? And how I can go about fixing it. If you need my code please let me know and I will provide it ASAP
Any help would be greatly appreciated! Thank you!

Answers (1)

Walter Roberson
Walter Roberson on 10 Apr 2023
There is nothing to fix.
Ideally the sum of squares would be exactly 0, which would require a perfect fit of parameters to the model and would require there be no round-off error.
lsqcurvefit knows that is not likely to happen, so it has several different stopping criteria. Some of the criteria cause a stop if the fit is taking longer than the maximum it has been configured for. Some of the criteria cause a stop if nan or infinities are encountered, making a solution impossible. Some of the criteria cause a stop if it can tell that the current location is unlikely to be an actual solution but it cannot figure out how to improve the solution.
And then there are criteria that lead to stopping when the result looks to be as good as you are likely to be able to get, that it does not seem worth looking for a better result anymore.
The particular criteria you are encountering is one that is in effect when the fit looks quite good and it doesn't seem worth chasing a better fit.
In some cases you need even more precise values; if so then there are options you can adjust to wait longer before deciding that further improvements are pointless.
In some cases, if your model deals with fairly small numbers, your fit might not really be any good and you need to adjust the options or scale the values. You need to have some understanding of the model to know whether a fit to within 10^-6 is good enough.
There is only one case in which lsqcurvefit could say definitively that it has found the model coefficients: that would be the case where the fit was exact right down to the last possible decimal place. That rarely happens. Instead the normal way for lsqcurvefit to end is to figure out that it has done as good of a fit as you are likely to get -- and then to say "but of course it is always possible that this is not really the best set of model parameters, that just maybe there is a better set of parameters somewhere".
Unless you get a fit right down to the last possible decimal place, then you will never know for sure that you really found the global minima -- not when you are doing numeric calculations. (In some cases it is possible to use symbolic calculations to prove that you have reached a global minima, but that gets difficult except for polynomials.)
  5 Comments
Walter Roberson
Walter Roberson on 11 Apr 2023
Can you attach your data for testing?
Daniel Alejandro Diaz
Daniel Alejandro Diaz on 11 Apr 2023
Edited: Daniel Alejandro Diaz on 11 Apr 2023
Hi Walter,
Absolitely! I apologize. I thopught I attached it but here it is! Also, I have been switching RE to change the height of the system. In other words Co control the height of the film and I change RE to change its eficiency thus changng the height. This is similar to the one I posted last night that you helped me with and said had a good fit. Only differency it that this has a different height and release behavior but the same expression to fit... I excpect Dab and RE to change to fit the data but currently I am using trial and error to get RE and use MATLAB to find DAB through the fit. I believe finding RE and Dab simultaneously with lsqcurvefit but I am not sure how to do that and have been unsuccessful when i try

Sign in to comment.

Categories

Find more on Interpolation 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!