Trouble using Curve Fitter tool

3 vues (au cours des 30 derniers jours)
Neelkumar
Neelkumar le 5 Juil 2023
Modifié(e) : Matt J le 7 Juil 2023
My objective is to take my data, and find the parameters that fit it given the model equation, which is correctly typed in the equation box. I am solving for the parameters, as I said, but am running into the error outputed on the bottom right of the screenshot. MatLab suggesting to utilize upper/lower bounds for my parameters, but I want the parameter values to be returned by the curve fitter, and in addition I do not know how I would go about putting bounds on them even if I did have values for them given that they are supposed to change for each data set that I input.
In addition, if anyone can help me confirm that 'exp' in my equation is registered as e by MatLab, thank you.
Anyone who can help me with my issue, please let me know how I can solve for these parameters. Thanks
  3 commentaires
Matt J
Matt J le 5 Juil 2023
Modifié(e) : Matt J le 5 Juil 2023
I do not know how I would go about putting bounds on them
How does your model make physical sense unless beta+k2*x and delta+k4*x are both non-zero for all x? There are no singularities apparent in your x,y data.
Also, is n supposed to be an unknown parameter? If so, shouldn't n be non-negative? And is it supposed to be an integer?
Neelkumar
Neelkumar le 5 Juil 2023
Yes to all of your questions, that is a helpful start on putting bounds. I am not sure I understand what you mean regarding apparent singularities in my x,y data. Could you restate?

Connectez-vous pour commenter.

Réponses (1)

Matt J
Matt J le 5 Juil 2023
Modifié(e) : Matt J le 5 Juil 2023
I am not sure I understand what you mean regarding apparent singularities in my x,y data.
If beta+k2*x=0 or delta+k4*x=0 then your model equation is undefined, and the curve will have a discontinuity at such points. Moreover, the curve could diverge to for x immediately to the right and left of those points. However we don't see such bad behavior in the plot of your curve samples.
There is likely some physical reason why beta+k2*x or delta+k4*x are not supposed to change sign over the range of x that you are fitting. Therefore, you will need to incorporate those constraints into your fit. Note that as of R2023a, lsqcurvefit can support arbitrary linear equality constraints like beta+k2*x>=0, so you might want to use that to do the fitting instead.
Yes to all of your questions
Therefore, you are confirming that n is an unknown integer. You cannot have integer constraints using any of the least squares fitting routines in the Curve Fit or Optimization Toolboxes. The simplest thing would be to repeat the curve fit multiple times, each time trying a different value of n=0,1,2,...,N up to some reasonable maximum N, which you would probably know from physical logic. A more complicated approach would be to include n in the list of unknowns, but use a solver like ga which supports integer constraints. For that, you would need to have the Global Optimization Toolbox.
  2 commentaires
Neelkumar
Neelkumar le 7 Juil 2023
Ok, this is very helpful, thank you. I am now having trouble using lsqcurvefit, as its telling me that my YDATA has to be a double, but I believe it is a double. I have attached my current window so that you can see. As I am sure you can tell, I am new to MATLAB and so any and all of your help is appreciated.
Do you know how I would put the constraint of beta+k2*x or delta+k4*x into the lsqcurvefit command? Like I said, I am still trying to learn it. In addition, would you be willing to double check my code and make sure that the other parts of my command are correct?
Again, thknk you so much for the help thus far.
Matt J
Matt J le 7 Juil 2023
Modifié(e) : Matt J le 7 Juil 2023
Your attempts to use lsqcurvefit do not resemble at all the syntax in the documentation (which I provided a link for in my last post). You should definitely read that, as well as the examples there.
Also, please only use screenshots when it is insufficient to type your code as text. Text is easier for us to copy/paste. Ideally also, you would run and demonstrate the code and its problems here in the forum, rather than on your own computer (example below) so we can be sure it isn't a problem in your environment.
a=1+2
a = 3

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by