How to extract the function from curve fitting tool in Matlab

I want to extract the function for my data points. I used interpolant witg linear method as indicated in the figure below.
Is it possible to extract a function for the new curve produced by curve fitting as i want to integrate the equation to get the area under the curve?

 Réponse acceptée

Steven Lord
Steven Lord le 22 Déc 2020
You can call integrate on the cfit object. See the documentation page for more information.

Plus de réponses (1)

Ameer Hamza
Ameer Hamza le 17 Déc 2020
Modifié(e) : Ameer Hamza le 17 Déc 2020
No, in the case of interpolated curve fitting, it is not possible to get a nice and simple equation. It uses several linear equations in a piecewise manner to create the curve. However, it is still possible to integrate it. First, export the model to the workspace by right-clicking it in the "Table of Fits" section. The export model (name it fittedmodel in this example) supports functional syntax to evaluate the value. For example, you can write
fittedmodel(0.01)
to get the value at x = 0.01. You can integrate it like this
integral(@(x) fittedmodel(x).', 0, 0.03)

3 commentaires

zein
zein le 22 Déc 2020
Modifié(e) : zein le 22 Déc 2020
Thanks for your reply
so if i want to integrate the function but i want to muliply by constant (1-1/22.49*fun)
q=integral(@(x) (1-(1/22.49)*fittedmodel(x).'), 0, 0.03)
Yes, this syntax is correct.
Is it possible to differentiate the save function for different values of x?

Connectez-vous pour commenter.

Catégories

Produits

Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by