Generating MATLAB Code and Exporting Fits
Interactive Code Generation and Programmatic Fitting
The Curve Fitter app makes it easy to plot and analyze fits at the command line. You can export individual fits to the workspace for further analysis, or you can generate MATLAB® code to recreate a fit and its opened plots. By generating code, you can use your interactive curve fitting session to quickly assemble code for curve and surface fits and plots into useful programs.
On the Curve Fitter tab, in the Export section, click Export and select Generate Code.
The Curve Fitter app generates code from your session and displays the file in the MATLAB Editor. The file includes the currently selected fit and its opened plots in your session. The file captures the following information:
Name of the fit and its variables
Fit settings and options
Curve or surface fitting object and the function used to create the fit:
sfitobject representing the fit
A structure with goodness-of-fit information
Save the file.
For more information on working with your generated code, exporting fits to the workspace, and recreating your fits and plots at the command line, see: