How can we automate Curve Fitting Tool (cftool) processes?

6 vues (au cours des 30 derniers jours)
I use the Curve Fitting Tool in my workflow. Right now my method is semi automated. I define variables as my stretch data, pull them up in cftool, fit with a gaussian fit. I then type in the a1, b1, and c1 variable outputs in the cftool results window and run my program which graphs the derivative and searches for the max value. How would you automate this process? It's about a ten minute process and I have a large amount of samples to run.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 26 Mai 2017
The "cftool" function has a feature that allows you to generate MATLAB code that will carry out the same fitting as you have set up in the tool.
This feature is located in the Curve Fitting Tool Window > File > Generate Code.
When you run the code generated by the tool, it will output a "cfit" or "fit" object, depending on what kind of fitting you are doing.
Once you have created this object, you can use the functions "coeffnames" and "coeffvalues" in order to access those a1, b1, and c1 values.
>>coeffvalues(fitresult)
So, to summarize, once you've generated code for your fit a single time, you can then re-run that function as many times as you need and thus automatically extract those values and automate the process.
For more information about generating code from the Curve Fitting Tool, please read the following guides:
https://www.mathworks.com/help/releases/R2017a/curvefit/generating-matlab-code-and-exporting-fits.html
https://www.mathworks.com/help/releases/R2017a/curvefit/generating-code-and-exporting-fits-to-the-workspace.html

Plus de réponses (0)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by