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

4 次查看(过去 30 天)
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.

采纳的回答

MathWorks Support Team
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

标签

尚未输入任何标签。

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by