This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Generating MATLAB Code and Exporting Fits

Interactive Code Generation and Programmatic Fitting

Curve Fitting 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 all fits and plots in your session. 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.

  1. Select File > Generate Code.

    The Curve Fitting app generates code from your session and displays the file in the MATLAB Editor. The file includes all fits and plots in your current session. The file captures the following information:

    • Names of fits and their variables

    • Fit settings and options

    • Plots

    • Curve or surface fitting objects and methods used to create the fits:

      • A cell-array of cfit or sfit objects representing the fits

      • A structure array with goodness-of fit information.

  2. 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: