Generated banner for Matlab Fit Curve
Generated logo for Matlab Fit Curve

Matlab Fit Curve

MathWorksOfficialCreated by MathWorks

  • Skill
  • Tool integration
  • Data and AI
  • BSD-2-Clause
  • Low risk

From the author

Fit curves and surfaces interactively with the Curve Fitter app for a complete no-code fitting workflow. Invoke this skill when the Curve Fitter app, cftool, curveFitter, or "curve fitting tool/app" is mentioned in any way. Also use when exploring or comparing fit types (regression, interpolation, smoothing, splines, custom equations); excluding outliers interactively; iterating on a fitting workflow; help choosing a fit type; and exporting to a figure, generating MATLAB code, fits to the workspace, and to Simulink Lookup Tables.
— the description by MathWorks

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured, no-code workflow for fitting curves and surfaces to data using the MATLAB Curve Fitter app. It supports the entire lifecycle of a fitting project, from initial data selection and model exploration to iterative refinement, outlier exclusion, and final export of results to the workspace, figures, or Simulink.

What it does

  • Launches the Curve Fitter app with specified data or session files
  • Enables interactive selection of regression, interpolation, and smoothing models
  • Provides tools for visual and numerical inspection of fit results
  • Supports iterative refinement through point-and-click outlier exclusion
  • Facilitates comparison of multiple fit models within a single session
  • Exports results to the MATLAB workspace, figures, or Simulink lookup tables

When to use it

  • When you need to fit models to data without writing manual code
  • When you want to explore multiple fit types to determine the best model
  • When you need to visually identify and exclude outliers from your dataset
  • When you require a visual comparison of different fitting approaches
  • When you need to generate Simulink lookup tables from your fitted data

Advantages

  • Provides a complete, intuitive graphical interface for complex fitting tasks
  • Allows for rapid iteration and visual feedback during model development
  • Maintains session state for easy collaboration and reproducibility
  • Supports seamless transition from interactive exploration to generated code

Usage examples

“Open the Curve Fitter app with my x and y variables.”
The agent launches the Curve Fitter app and loads the specified workspace variables for fitting.
“Compare a polynomial fit and a smoothing spline for my data.”
The agent creates two separate fits in the app, allowing you to compare their goodness-of-fit metrics and visual plots.
“Exclude the outliers in the current plot.”
The agent enables interactive exclusion mode, allowing you to select and remove specific data points from the fit.
“Export my current fit to the workspace.”
The agent exports the fit object and goodness-of-fit statistics to your MATLAB workspace.

Install

Documentation by MathWorks

Interactive Curve and Surface Fitting

Guides interactive curve and surface fitting through the Curve Fitter app as part of the Curve Fitting Toolbox. Covers the full in-app workflow of selecting data, exploring fit types, modifying with fit options, inspecting fits visually and numerically, then exporting results.

When to Use

No-code fitting

  • Users who want to fit curves or surfaces without writing code

  • Users who want to start interactively and generate code later to continue in the command line

Interactive exploration

  • Exploring fit types when the best model is unknown

  • Iterating on fits with visual feedback

  • Maintaining and comparing multiple fits in a single session

  • Discovering available fit types, options, and features

App-specific features

  • Exporting fits to Simulink lookup tables (only available through the app)

  • Excluding data points or regions iteratively with visual feedback

  • Loading or continuing a saved session (.sfit) for convenience or collaboration

When NOT to Use

CLI workflows (no app involvement)

  • User is already writing code and does not want the app involved

  • Using fit(), fittype(), fitoptions() directly in their own scripts/functions

  • The desired fit type, data, and options are already known and the user wants code

  • Many fits that would be difficult to manage in the app

Spline workflows

  • Spline CLI functions (csapi, csaps, fnbrk, etc.)

  • splinetool or bspligui apps

Other tools and domains

  • Base MATLAB functions — interp1, pchip, scatteredInterpolant, griddedInterpolant, spline, smoothdata

  • Basic Fitting tool — polynomials, spline interpolant, pchip interpolant; built into MATLAB figures

  • Statistics and Machine Learning Toolbox — statistical modeling, cross-validation, dataset partitioning, separate test data (fitlm, fitnlm, cvpartition)

  • Optimization Toolbox — any workflow using Optimization Toolbox functions (lsqnonlin, fmincon, lsqcurvefit, lsqlin)

If CLI is the better approach, do not suggest app workflows. If neither section clearly applies, use these signals to disambiguate:

SignalRecommendationWhy
User says "compare" fitsDependsVisual curve comparison -> CLI (overlaid on same axes). Comparing goodness of fit metrics -> App (Table of Fits). Interactive adjustment -> App.
User just wants to visualize a single fitCLICLI plotting handles this well
User wants to overlay multiple fits on same axesCLIApp shows fits in separate figures only
User needs to exclude outliers by visual inspectionAppPoint-and-click exclusion is easier than computing indices
User needs formal validation dataAppThe app has explicit validation data support

User instructions always take precedence. If the user explicitly asks for CLI code — even mid-app-workflow — write CLI code. The agent may also offer CLI as an alternative when the controller cannot fulfill a request.

Do not spontaneously switch between app and CLI mid-workflow. If the user's intent is still unclear after consulting the table above, ask whether they prefer working interactively in the app or with code.

If the user asks how to perform a workflow themselves, where to find a feature in the UI, or whether a capability is available in the app, see references/curve-fitter-layout.md for the full layout and feature locations.

Must-Follow Rules

Release Compatibility
  1. Use cftool for R2021b and earlier; curveFitter for R2022a+ — never instruct the user to use both in the same workflow. Users often say "cftool" out of habit on R2022a+ — still use curveFitter or the controller regardless of user terminology.

  2. CurveFitterAppController (scripts/CurveFitterAppController) requires R2022a+ — it will error on earlier releases. On R2021b and earlier, the agent CANNOT read or write app state programmatically. The only programmatic interaction is cftool input arguments (cftool(x, y), cftool(x, y, z), etc.). All other actions (changing fit types, excluding points, exporting) must be performed by the user through the app UI — guide them using general knowledge of cftool, don't promise action. getFittypeTable() still works independently for discovering fit types. On R2022a+, prefer the controller's open* methods to launch the app (they handle version checking internally). On pre-R2022a, set expectations upfront: everything besides launching the app or launching the app with data is unsupported for agentic workflows on this release — you can guide the user through the UI but cannot perform actions for them. Offer CLI fitting as an alternative path. Don't let users discover limitations one by one.

    Critical for pre-R2022a: On these releases, ALL of the following apply:

    • Refer to the app ONLY as "cftool" or "the Curve Fitting Tool" — never "Curve Fitter"

    • Do not mention ANY controller method names (setExclusionRule, setFittype, etc.) — they do not exist on this release

    • Do not imply you can perform actions inside the app — you cannot

    • If the user says "Curve Fitter" on R2021b or earlier, say "The Curve Fitter app isn't available in [release]. I'll use cftool instead."

API Usage
  1. Drive the app workflow via the controller API — do not spontaneously switch to CLI — once the app is open or the user is working in the app, fitting, comparison, and exclusion work goes through the controller. Do not spontaneously generate CLI fit() code as a substitute for app actions. Do not pause and instruct users to click UI elements. Exceptions:

    • The user explicitly requests CLI code (user instructions always take precedence)

    • The controller has no API for the requested action — guide the user through the app UI via references/curve-fitter-layout.md first. Only offer CLI as an alternative if the feature isn't available in the app or the workflow is trending toward the ambiguous signals in "When NOT to Use"

    • The user explicitly says they want to perform actions themselves in the UI

  2. Internal CLI execution is permitted for efficiency — the agent can internally execute fit(), fittype(), fitoptions(), etc. for quick lookups (e.g., surveying multiple fit types, checking available fit options) without generating user-facing code or mentioning it in responses. This is distinct from generating code for the user.

  3. If a controller method errors, read the error and react — the messages are informative and will guide you to fix the syntax or inform the user.

  4. Use getFittypeTable() (scripts/getFittypeTable) to discover available fit types — do not guess or assume the availability of fit type names or prioritize custom equations when a built-in one exists. To inspect a specific fit type, create a fittype object and use its methods (formula, coeffnames, islinear, etc.) — fittype objects have no public properties. Never assume or state that data "looks like" or "is suitable for" a specific model — ask the user about their data characteristics or goals instead.

  5. Read the minimum relevant state before taking actions that depend on it — do not blindly execute commands without checking prerequisites (e.g., check dimensionality before setting a curve-only fit type, check that a fit exists before exporting). Do not read the full app state for every action — only what the specific action requires.

Reporting Results
  1. Never make subjective value judgments on fit quality — but factual interpretation is allowed — report all relevant goodness-of-fit metrics (not just R²) and let the user interpret. Factual, objective statements about statistical properties and tradeoffs are permitted and encouraged — these are distinct from subjective quality judgments. Do not suggest alternative fit types or approaches unless the user explicitly asks. See references/interpreting-fit-results.md for the full list of prohibited terms, permitted factual statements, and guidance on how to handle direct quality questions.

Agent Behavior
  1. Load references before acting (silently) — these are mandatory, not optional. Load liberally — when in doubt about whether you need a reference, load it. Never narrate or mention loading references in user-facing text (see Rule 10):

    • Load references/api-reference.md before calling any controller method for the first time in a session

    • Load references/interpreting-fit-results.md before reporting, comparing, or explaining fit results

    • Load references/curve-fitter-layout.md before answering questions about app features, UI locations, or when the controller has no API for a requested action

    • Scope: curve-fitter-layout.md covers R2022a+ (Curve Fitter) ONLY. It can indicate what features exist in cftool, but NOT where they are located in the UI. For cftool UI locations: rely on general knowledge, and when unsure say so rather than guessing.

    • Never describe UI elements not documented in references — if you don't know what an icon looks like or where a button is, say "I'm not certain of the exact location" rather than inventing details.

  2. The controller is invisible to the user — everything about the controller, API, and reference files is an internal implementation detail. In user-facing responses:

    • CRITICAL — most common violations: "let me add the controller scripts to the path", "using the controller", "the controller's X method", "programmatically". These MUST NOT appear in any user-facing text including narration, status updates, and thinking-aloud.

    • Never mention controller class names, method names, or API syntax (e.g., don't say "I'll use setExclusionRule" — say "I'll exclude those points")

    • Never narrate internal implementation steps — don't say "let me add the controller scripts to the path", "the controller is available", "I'll use the controller to set the fit type", or "using the controller's openAppWithData method." These are invisible mechanics. From the user's perspective, you are simply performing actions in the Curve Fitter app.

    • Never mention reference file names or loading (e.g., don't say "let me check the API reference")

    • The act of loading references is itself invisible — do not say "let me check", "let me read", or "let me look up" before loading a reference file. Just load it silently and proceed.

    • Never mention the concept of a "controller" or explain that one exists or doesn't exist for a given release

    • Never mention "programmatic" control of the app — just offer actions naturally (e.g., "Would you like me to change the fit type?" not "I can programmatically set the fit type")

    • Never explain internal release reasoning (e.g., don't say "since the controller isn't available on this release" — just guide the user appropriately)

    • When no controller API exists for a requested action, guide the user through the app UI using references/curve-fitter-layout.md

    • Do not invent programmatic workarounds

  3. Ask before acting on ambiguity — when a user's request is vague or underspecified (e.g., "take care of that point", "fix this", "clean up the data"), ask the user to clarify what they want before acting. For example, if excluding points, ask which points or what criteria to use. Never apply an arbitrary exclusion criterion (2σ, isoutlier, etc.) without user confirmation. When the user asks generically about handling or dealing with outliers (not specifically asking to exclude), present the relevant options: exclusion (interactive or rule-based) removes points from fitting, while robust fitting down-weights outliers without removing them. When the user specifically asks to exclude points, only present exclusion methods — don't suggest robust fitting as an alternative. When app state changes unexpectedly (fits disappear, session resets), describe what you observe and ask how to proceed rather than taking corrective action autonomously.

  4. Use release-appropriate terminology in responses — for R2022a+, always refer to the app as "Curve Fitter" (not "cftool"). If the user says "cftool" on R2022a+, acknowledge their term and clarify that cftool isn't available in this release and that you'll be using Curve Fitter. For R2021b and earlier, refer to the app as "cftool" or "the Curve Fitting Tool" — never "Curve Fitter" or "Curve Fitter app." If the user asks to open "Curve Fitter" or "curveFitter" on R2021b or earlier, clarify that it isn't available in this release and that you'll be using cftool.

  5. Use display names, not library model names, in user-facing text — library model names (exp1, poly2, rat11, lowess, loess, smoothingspline) are for programmatic use only (controller calls, scripts). In user-facing responses, use the display names from the Fit Type Gallery: "Exponential (1 term)", "Polynomial (degree 2)", "Rational (1/1)", "Smoothing Spline", "Lowess (Linear)", etc.

  6. Trust live app state over conversation memory — always trust getter call results over what was true earlier in the conversation. Read state before acting on it. If state conflicts with what the user described, report the actual state factually. Don't diagnose unexpected state changes as bugs — the user can change the app between turns.

  7. Report WARNING states and convergence messages — after completing a fit action, if the fit has a WARNING state or convergence messages, report them to the user and ask if they want to address them. Don't silently ignore, and don't automatically "fix" them. Exception: if the user has already acknowledged or explicitly dismissed warnings.

  8. Confirm with the user before importing or exporting — any action that moves data into or out of the app requires explicit user confirmation before execution. State what you plan to do (file name, variable names, breakpoint values, etc.) and why you're asking (what's ambiguous or what choices you made), then wait for approval. Specific scenarios:

    • Saving a session — state the session name and file path before saving (e.g., "I'll save the session as myfit.sfit at C:\Users\.... OK?")

    • Loading a session — if exactly one .sfit file is detected, it can be loaded directly. If multiple exist and the user's request is ambiguous, state what you found and propose your selection (e.g., "There are multiple session files — is analysis.sfit the correct one?"). Do not load until confirmed.

    • Selecting fitting/validation data — if the correct variables are unambiguous from the prompt or workspace, proceed. If multiple candidate variables exist (e.g., x, x2, y, y2), explain the ambiguity, propose your selection, and confirm before acting (e.g., "There are several numeric variables in the workspace — I'll use x and y as the fitting data. Is that correct?"). Do NOT launch the app or select data until confirmed.

    • Exporting variables to workspace — propose variable names and explain what will be exported before acting (e.g., "I'll export the fit object as fitresult and goodness of fit as gof to the workspace. OK?")

    • Exporting to Simulink LUT — state the breakpoint values/scheme you plan to use and confirm before executing. If the user didn't specify breakpoints, propose reasonable values and wait for approval.

    Rule 16 does NOT apply to: exporting to a figure, generating code from the app, or starting a new session — these are non-destructive or already have built-in app-level dialogs.

Workflow

Fitting Workflow:
- [ ] Step 1: Select data
- [ ] Step 2: Choose a fit type
- [ ] Step 3: Choose fit options
- [ ] Step 4: Fit
- [ ] Step 5: Evaluate and visualize results
- [ ] Step 6: Iterate and compare
- [ ] Step 7: Export, save, or share results

This workflow applies per fit. Most sessions involve one or a few fits, but additional fits can be created at Step 6 to compare approaches.

Entry Points
  • Select Curve Fitter from the Apps gallery under the Apps tab in the MATLAB Toolstrip

  • For R2021b and earlier releases: cftool(...) (do not use curveFitter)

  • For R2022a and later releases: curveFitter(...) (do not use cftool)

Both commands share the same input argument syntax:

  • curveFitter() — launch the app with no data, or bring an already-open app to focus

  • curveFitter(x, y, z, w) — launch with data, or create a new fit in an already-open app. Provide [] to omit an argument (e.g., use (x, y, [], w) for weighted curve fitting)

  • curveFitter('file.sfit') — load a saved session (must be a .sfit file)

Note: In agentic workflows (R2022a+), use the controller's openAppWithData() and openSession() methods instead of calling curveFitter(...) directly. They automatically detect and dismiss startup alert dialogs and return the alert text for reporting to the user.

Programmatic Control

Instantiate CurveFitterAppController (scripts/CurveFitterAppController) for read/write API access in agentic workflows. Only supported in R2022a and later. See references/api-reference.md for the full API — all controller methods referenced in the steps below are documented there.

Launching the app: Use openAppWithData() or openSession() to launch the app with data or a session file. These handle launch waiting, app handle management, and automatic dismissal of any alert dialogs. Always capture the returned alertText — if non-empty, report it to the user before proceeding.

Relevant controller methods:

  • openApp(), openAppWithData(), openSession(), closeApp()

Step 1: Select Data

Assign fitting data from workspace variables. Optionally add validation data for independent fit assessment, and define exclusion rules or exclude individual points.

Relevant controller methods:

  • selectFittingXData(), selectFittingYData(), selectFittingZData(), selectFittingWData()

  • selectFittingXDataFromTable(), selectFittingYDataFromTable(), selectFittingZDataFromTable(), selectFittingWDataFromTable()

  • getFittingDataVariableNames(), isSurfaceFit()

  • selectValidationXData(), selectValidationYData(), selectValidationZData()

  • selectValidationXDataFromTable(), selectValidationYDataFromTable(), selectValidationZDataFromTable()

  • getValidationDataVariableNames()

  • setExclusionRule(), getExclusionRules(), clearAllExclusionRules()

  • toggleInteractiveExclusions(), getInteractiveExclusions(), clearAllInteractiveExclusions()

Step 2: Choose a Fit Type

Choose a fit type based on the selected data. Built-in library models include Regression (Polynomial, Exponential, Power, Fourier, Gaussian, etc.), Interpolants, and Smoothing fit types. Custom linear and nonlinear equations are also supported, including equations defined in separate files.

To discover all available built-in fit types for the current release, run getFittypeTable() (scripts/getFittypeTable). Pass "curve" or "surface" to filter by dimensionality if known. The returned table includes a category column — the category "library" specifically refers to regression fit types. To inspect a specific fit type, create a fittype object and use its methods (formula, coeffnames, islinear, etc.) — fittype objects have no public properties.

Relevant controller methods:

  • setFittype(), getFittype()

  • getFittypeTable() (utility script)

Step 3: Choose Fit Options

Optional unless the user wants to adjust fit quality or behavior. To discover which options are available for a given fit type, call fitoptions(fittypeString) in MATLAB — this returns a fitoptions object showing all settable properties and their current/default values.

Relevant controller methods:

  • setFitOptions(), getFitOptions()

Step 4: Fit

If auto-fit is enabled (default), fitting occurs automatically when data or fit type changes. If manual mode is selected, explicitly execute the fit.

Relevant controller methods:

  • runFit()

  • setAutoFit(), getAutoFit()

Step 5: Evaluate and Visualize Results

After fitting, check the fit status for errors, warnings, or convergence issues. Review goodness of fit metrics and inspect the fit visually — add residuals plots, contour plots, or prediction bounds if applicable and relevant.

Relevant controller methods:

  • getFitState(), getFitStatusMessages()

  • getGoodnessOfFit(), getGoodnessOfValidation()

  • getFormula(), getCoefficientNames(), getCoefficientValues(), getCoefficientConfidenceIntervals()

  • getResultsPanelText()

  • getFitInformation()

  • setResidualsPlotVisibility(), getResidualsPlotVisibility()

  • setContourPlotVisibility(), getContourPlotVisibility()

  • setPredictionBoundConfidenceLevel(), getPredictionBoundConfidenceLevel(), clearPredictionBounds()

  • setFitPlotVisibility(), getFitPlotVisibility()

  • setLegendVisibility(), getLegendVisibility()

  • setGridVisibility(), getGridVisibility()

Step 6: Iterate and Compare

If unsatisfied, iterate on the current fit by adjusting the fit type, options, or exclusions (repeat steps 2-5). To compare multiple approaches, create additional fits — each maintains its own data, fit type, options, and results independently.

Relevant controller methods:

  • createNewFit(), duplicateFit()

  • selectFit(), renameFit(), deleteFit()

  • getAllFitNames(), getFitName()

  • getAllFitInformation()

Step 7: Export, Save, or Share Results

Export results to transition to other workflows (Simulink, CLI scripts), save the session for later use, or share it with others.

Relevant controller methods:

  • exportFitToWorkspace()

  • exportToFigure()

  • generateCode()

  • exportToSimulinkLUT(), exportToSimulinkLUTEvenSpacing(), launchOptimizedLookupTableWizard()

  • saveSession(), saveSessionAs()

  • hasUnsavedChanges(), getSessionInfo()

  • openSession(), startNewSession()

Efficiency Patterns

  • Prefer duplicateFit() over createNewFit() + re-selecting data — when creating a comparison fit that uses the same data, duplicate preserves everything about the current fit: name (with "copy N" appended, incrementing), fitting data, validation data, fit type, fit options, exclusions, and visualization settings — not just the data

  • Read current state before making changes — before switching fit types or modifying options, read the current metrics and settings so results can be compared to the previous state

  • Proactive state reads prevent error-recovery cycles — check prerequisites (data dimensionality, fit existence, fit state) before attempting actions that will error without them

Conventions

Reporting Results
  • Report all relevant goodness of fit metrics (SSE, R-square, Adjusted R-square, RMSE, DFE)

  • Include validation metrics when validation data is present

  • When reporting FitState, translate: GOOD → "Complete", WARNING → "Warning", ERROR → "Error", INCOMPLETE → "Incomplete". Never use "Good" as a fit state label — users will interpret it as a quality judgment.

  • Never characterize fit quality subjectively — present numbers and context

  • See references/interpreting-fit-results.md for how to present, compare, and explain metrics to users

Workflow Approach
  • For multi-step or complex actions, understand the current state first, identify the commands and inputs needed, then execute sequentially

  • Improving a fit is a multidimensional problem — when the user wants to improve a fit or address issues, the main levers are: fit type selection (or trying multiple fit types), fit options (start points, bounds, algorithm, robust fitting), and exclusions. All should be considered, not just one. Typically: exclusions and data cleaning come first, then fit type selection, then fit options — but the user may approach in any order

  • Inspect data before fitting when the goal is ambiguous — if the user hasn't specified a fit type or approach, silently analyze the data (dimensions, range, distribution, obvious patterns) to inform suggestions. Scale inspection effort to ambiguity: clear requests ("fit a polynomial") need no inspection; open-ended requests ("find the best fit") benefit from it

Agent Behavior
  • Report consequences, not elaborations — after completing an action, explain what happened as a result (including side effects like a fit completing due to auto-fit), but do not add further detail or analysis beyond the direct consequences. For example, if loading data triggers a default fit, mention that a fit completed — but don't report metrics, coefficients, or quality assessments unless the action itself was about fitting or the user asked. If a visualization is toggled, report that it is now showing — but don't analyze or summarize its content unless asked. Keep responses proportional to the action taken.

  • Per-fit scope — unless specified, app controls and controller methods apply to the currently selected fit only. Some actions may reasonably apply to multiple fits — selecting fitting/validation data or applying exclusion rules could apply to all fits with the same data. If the user's request doesn't explicitly state scope and the action could plausibly affect one or all fits, ask whether it should apply to the current fit or all fits before proceeding.

  • Never fabricate technical explanations — if an unexpected error arises that you don't recognize or know how to resolve, report the observable behavior factually. Never invent internal implementation details, diagnose bugs in the app code, name internal methods/classes, or speculate about access permissions or configuration issues. When an error has no immediate or clear programmatic fix, fall back to the UI: consult the layout reference and guide the user through achieving the action manually in the app. This applies to ALL unexpected errors, not just known limitations.

  • Let the user drive the workflow — don't suggest or assume their next step. Present results and wait for direction.

  • Follow user instructions precisely — don't add extra actions beyond what was requested without confirming first.

  • Don't explain internal release reasoning or implementation details to users — they know their own release.


Copyright 2026 The MathWorks, Inc.


Files

references/curve-fitter-layout.md

Curve Fitter App Layout (R2022a+)

This describes the modern Curve Fitter app opened via curveFitter(...).

Table of Contents

  • Version Convention

  • Overview

  • Toolstrip

    • File Section

    • Data Section

    • Fit Type Section

    • Fit Section

    • Visualization Section

    • Preferences Section

    • Export Section

  • Fit Options Panel

    • Regression Models

    • Interpolation

    • Smoothing

    • Custom

    • Saved Custom Equations

    • Advanced Options

  • Results Panel

  • Table of Fits

  • Fit Figure Area


When to Use This Reference

Consult this reference when:

  • The user asks how to perform an action in the app UI

  • The user asks where to find a feature or what a control does

  • The controller has no API for a requested action — guide the user through the app UI instead of inventing a workaround

  • The user mentions a feature by name and you need to confirm its existence and location

This reference only covers the modern Curve Fitter app (R2022a+). It does not cover cftool (R2021b and earlier). For cftool, most of the same functionality exists but with a different layout — rely on general knowledge for cftool feature locations. Functionality introduced after R2022a (annotated with release tags below) is not available in cftool.


Version Convention

All features described in this document are available in R2022a and later unless annotated. Annotations use:

  • Callout blocks (>) for entire new sections or behavioral changes that need explanation

  • Bold inline tags like (R2024b+) for individual new features within existing sections

Per-fit scope: Unless otherwise specified, all controls in the Curve Fitter app (toolstrip, Fit Options panel, Fit Figure) apply to the currently selected fit only. This includes data selection, validation data, fit type, fit options, exclusions, and visualization settings. To apply changes across multiple fits, select each fit tab individually.


Overview

The app has four main regions:

RegionPositionContents
ToolstripTopRibbon-style toolbar with sections: File, Data, Fit Type, Fit, Visualization, Preferences, Export
Fit FigureCenterPlot area with tabs (one tab per fit)
Fit Options + ResultsRight sideStacked panels showing options and results for the selected fit
Table of FitsBottomSpreadsheet-style table listing all fits and their metrics

Each fit gets its own figure tab. Selecting a fit (via tab click or Table of Fits row click) updates the Fit Options and Results panels to show that fit's configuration and output.


Toolstrip

The toolstrip has a single tab ("Curve Fitter") with the following sections from left to right:

File Section
ControlTypeAction
NewSplit dropdownNew Session — discards current session and starts fresh; New Fit — adds a new fit to the current session
OpenButtonOpens a saved .sfit session file
SaveSplit buttonSave (top) — saves to current path; Save Session As... — saves to a new file
DuplicateButtonDuplicates the currently selected fit

Session management:

  • Sessions are saved as .sfit files and preserves the exact state of the app when it was saved

  • The title bar shows "Curve Fitter" when no session file is associated. Once saved, it changes to "Curve Fitter - <name>" (without the .sfit extension)

  • Use hasUnsavedChanges via the controller to check for unsaved modifications

  • Opening a session replaces the current session entirely

  • If there are unsaved changes and the user closes the app, starts a new session, or loads a session, a confirmation dialog appears asking "Would you like to save your current session?" with buttons: Save, Don't Save, Cancel

Data Section
ControlTypeAction
Select DataButtonOpens the "Select Fitting Data" dialog
Exclusion RulesButtonOpens the "Exclusion Rules" dialog
Validation DataButtonOpens the "Select Validation Data" dialog

Select Fitting Data dialog: Contains an editable Fit name text field, and dropdowns for X data, Y data, Z data (surface only), and Weights. Each dropdown lists numeric vectors and table variables from the workspace. When a table variable is selected, a second dropdown appears to choose the column name. Info, warning, or error messages related to the selected data (e.g., size requirements, NaN/Inf values, dimension mismatches) appear at the bottom of the dialog and in the Results panel. Buttons: Help, Close.

Select Validation Data dialog: Shows the Fit name (read-only label), and dropdowns for X data, Y data, and Z data (surface only). Same workspace variable/table-column selection as fitting data. No Weights field. Buttons: Help, Close.

Exclusion Rules dialog: Shows the Fit name (read-only label). For each dimension (X, Y, Z for surfaces), provides two exclusion conditions side by side — each with an operator dropdown (<, <=, >, >=) and a value text field. This allows excluding data outside a range per dimension. Duplicate rules are prevented by the UI design. Buttons: Help, Close.

Fit Type Section
ControlTypeAction
Fit Type GalleryGallery with popupShows up to 4 fit types inline (fewer if the window is narrow); clicking the dropdown arrow opens the full gallery popup

Gallery popup structure:

The popup has a search bar, list/grid view toggle, and category filter dropdown ("REGRESSION MODELS"). Categories can be reorganized with the up/down arrows:

CategoryFit Types
REGRESSION MODELSPolynomial, Exponential, Logarithmic, Fourier, Gaussian, Power, Rational, Sum of Sine, Weibull, Sigmoidal
INTERPOLATIONInterpolant
SMOOTHINGSmoothing Spline, Lowess
CUSTOMCustom Equation, Linear Fitting

Fit types that don't apply to the current data dimension are grayed out (e.g., Lowess is surface-only; Smoothing Spline is curve-only). Surface fit types show 3D plot icons instead of 2D and the icon for fit types that support both curves and surfaces will toggle depending on what data is selected.

Fit Section
ControlTypeAction
Update FitRadio groupAuto — fit updates automatically when data or options change; Manual — requires clicking "Fit"
Fit / StopButtonExecutes the fit; grayed out when Auto is selected. While fitting is in progress, changes to a Stop button that can be clicked to cancel the fit

Manual mode behavior: When Manual is selected and any change is made (data, options, etc.), the fit state becomes INCOMPLETE and the Results panel displays a message instructing the user to click the Fit button. The Fit button icon changes depending on whether Auto or Manual is selected. Manual mode is recommended when making many small changes to avoid re-fitting after every individual change.

Visualization Section
ControlTypeAction
Fit PlotToggle buttonToggles the main fit plot; can be turned off if at least one other plot (Residuals or Contour) is visible
Residuals PlotToggle buttonToggles residuals stem plot
Contour PlotToggle buttonToggles 2D contour plot (surface fits only; disabled for curves)
Prediction BoundsDropdownOptions: None, 90%, 95%, 99%, Custom (Custom opens a dialog to enter a confidence level percentage). Disabled when constraint points are active on the current fit; re-enabled when all constraint points are removed.

At least one plot must be visible at all times — the toggle button for the last remaining visible plot is disabled. To switch from one plot to another (e.g., showing only Residuals instead of only Fit Plot), first enable the desired plot, then disable the one to remove.

Set Prediction Bounds dialog (Custom): Contains a Fit name (read-only label) and a Confidence level (%) editable numeric field (default: 95). Buttons: Help, OK, Cancel. If the entered value matches a predefined option (90%, 95%, or 99%), the dropdown switches to that option after OK. Otherwise (e.g., 92%), the dropdown stays on "Custom". The user can select Custom again to change the value, pick a predefined level, or select None to turn off prediction bounds.

R2023b+: The Custom dialog was updated to show the fit name and include a Help button. In R2022a–R2023a, the dialog had only the confidence level field with OK/Cancel.

Preferences Section

R2024b+: This entire section is not present in earlier releases.

ControlTypeAction
ColormapButtonOpens the "Curve Fitting Toolbox Colormap Preferences" dialog

Colormap Preferences dialog: Contains a colormap dropdown (default: "Default"), a Reset button, and a colormap preview bar. The default colormap is "sky" (light theme) or "abyss" (dark theme). Changing the selection affects surface plots both in the app and at the command line (e.g., sfit/plot). The setting persists across sessions.

Export Section
ControlTypeAction
ExportDropdown buttonOpens a dropdown menu

Export dropdown contents:

  • Export to Figure — exports a copy of the currently displayed fit's plot(s) to a standalone MATLAB figure window

  • Generate Code — generates MATLAB code reproducing the fit

  • Export to Workspace — opens the "Save Fit to MATLAB Workspace" dialog to export the fit object, goodness-of-fit struct, and/or output struct to workspace variables

  • Export to Simulink (R2022b+) (requires Simulink) — submenu with two options:

    • Create Lookup Table Block — opens the "Create Lookup Table Block" dialog to create a Simulink lookup table block by specifying breakpoints for the fit

    • Create Optimized Lookup Table (R2024a+) — opens the Lookup Table Optimizer wizard (requires Fixed-Point Designer)

Save Fit to MATLAB Workspace dialog: Contains three checkboxes with editable variable name fields:

CheckboxDefault NameDescription
Save fit to MATLAB object namedfittedmodelExports the cfit/sfit fit object
Save goodness of fit to MATLAB struct namedgoodnessExports the goodness-of-fit struct
Save fit output to MATLAB struct namedoutputExports the fit output struct

Buttons: OK, Cancel.

Create Lookup Table Block dialog: Creates a Simulink lookup table block by specifying breakpoints.

  • Fit name — read-only, shows the source fit

  • Breakpoints specification — dropdown: "Even spacing" or "Explicit values"

  • Even spacing mode: Breakpoints 1 (X data): First point, Spacing, Number of points (spinner). For surface fits: Breakpoints 2 (Y data) with the same fields.

  • Explicit values mode: Breakpoints 1 (X data): text field accepting MATLAB colon notation (e.g., 1800:20:2000) or an explicit vector (e.g., [1800 1850 1900 2000]). For surface fits: Breakpoints 2 (Y data) with same format.

  • Lookup table preview (R2023a+): scrollable table of the evaluated fit values at the specified breakpoints. For surface fits, a dropdown selects which Breakpoints 2 slice to display, and the table shows a 2D grid (rows = BP1, columns = BP2). In R2022b, breakpoints are specified without a preview.

  • Buttons: Help, Export Table to Simulink, Cancel.

Lookup Table Optimizer wizard: Requires Fixed-Point Designer. A multi-step wizard with tabs: Objective, Setup, Create, Results. The first page (Setup) includes Curve or Surface Fit Object name, Output Data Type, and a table of Input/Data Type/Minimum/Maximum. Upon completion, a Simulink model opens showing the optimized lookup table block. Creates a memory-efficient lookup table optimized for embedded targets.


Fit Options Panel

Located in the upper-right side panel. Shows options specific to the selected fit type. Has a kebab menu (three dots) with Maximize and Collapse Panel.

Regression Models
Polynomial
  • Degree dropdown (1-9); for surfaces: X Degree (1-5) + Y Degree (1-5)

  • Robust dropdown: Off, LAR, Bisquare

  • Center and scale checkbox

  • Advanced Options (linear)

Exponential
  • Equation display (read-only)

  • Number of terms dropdown

  • Center and scale checkbox

  • Advanced Options (nonlinear)

Logarithmic

R2023b+: This fit type is not available in earlier releases.

  • Equation display

  • Logarithm Base dropdown: e (natural), 10, 2

  • Robust dropdown: Off, LAR, Bisquare

  • Advanced Options (linear)

Fourier
  • Equation display (read-only)

  • Number of terms dropdown

  • Center and scale checkbox

  • Advanced Options (nonlinear)

Gaussian
  • Equation display (read-only)

  • Number of terms dropdown

  • Center and scale checkbox

  • Advanced Options (nonlinear)

Power
  • Equation display

  • Number of terms dropdown (1, 2)

  • Advanced Options (nonlinear)

Rational
  • Numerator degree dropdown (0-5)

  • Denominator degree dropdown (1-5)

  • Center and scale checkbox

  • Advanced Options (nonlinear)

Sum of Sine
  • Equation display (read-only)

  • Number of terms dropdown

  • Center and scale checkbox

  • Advanced Options (nonlinear)

Weibull
  • Equation display (static)

  • Advanced Options (nonlinear)

Sigmoidal

R2023b+: This fit type is not available in earlier releases.

  • Model dropdown: Logistic, 4-Parameter Logistic, Gompertz

  • Equation display

  • Center and scale checkbox (disabled for 4-Parameter Logistic)

  • Advanced Options (nonlinear)

Interpolation
Interpolant
  • Interpolation method dropdown: Nearest, Linear, Shape-Preserving (PCHIP), Cubic; for surfaces: Nearest, Linear, Natural (R2024a+), Cubic, Biharmonic (v4), Thin-plate

  • Extrapolation method dropdown (options change based on interpolation method; for surface Biharmonic/Thin-plate: automatic, not selectable). Additional extrapolation options for some methods (R2023b+).

    R2023a+: The extrapolation method dropdown was added. In R2022a–R2022b, interpolants use their built-in extrapolation behavior with no user control.

  • Center and scale checkbox (default ON)

  • No Advanced Options

Smoothing
Smoothing Spline (curves only)
  • Smoothing Parameter: Default (radio) / Specify (radio) + value field

  • Smoother / Rougher buttons (adjust on logarithmic scale)

  • Center and scale checkbox

  • No Advanced Options

Lowess (surfaces only)
  • Polynomial dropdown: Linear, Quadratic

  • Span (%) edit field (1-100)

  • Robust dropdown: Off, LAR, Bisquare

  • Center and scale checkbox (default ON)

  • No Advanced Options

Custom
Custom Equation
  • Saved options controls (R2025a+): "Select to apply" dropdown, Save button (disk icon), Manage button (see Saved Custom Equations below)

  • Independent/Dependent variable fields

  • Equation text area (multiline)

  • Shortcuts dropdown

  • Advanced Options (nonlinear)

Linear Fitting
  • Saved options controls (R2025a+): "Select to apply" dropdown, Save button (disk icon), Manage button (see Saved Custom Equations below)

  • Independent/Dependent variable fields

  • Coefficients/Terms table with editable coefficient names and term expressions, Add/Delete buttons

  • Shortcuts dropdown

  • Advanced Options (linear)

Saved Custom Equations (R2025a+)

All three custom fit type panels (Custom Equation for curves, Custom Equation for surfaces, Linear Fitting) share the same save/apply/manage workflow for reusing equations and fit options.

"Select to apply" dropdown: Lists previously saved equations for this panel type. This is an action dropdown — clicking an entry immediately applies the saved equation and options to the current fit, then resets back to "Select to apply". Modifying options after applying does not affect the saved entry.

Save Equation and Fit Options dialog (opened via the save button):

  • Name — editable text field for naming the saved equation

  • Equation — read-only display of the current equation

  • Advanced Fit Options — collapsible section (collapsed by default) showing the current fit options and Coefficient Constraints table as configured in the fit options panel at the time of saving

  • Buttons: Save, Cancel

Manage Saved Equations and Options dialog (opened via the manage button):

  • Three tabs: Custom Equation (Curve), Custom Equation (Surface), Linear Fitting

  • Each tab shows a table of saved equations with columns: checkbox, Name, Equation, Independent Variable(s), Dependent Variable

  • Remove button (top-right, enabled when one or more rows are checked) — deletes selected entries

  • Buttons: Close

  • New equations cannot be added from this dialog — save from the fit options panel instead

Advanced Options (collapsible section)

Present on regression and custom fit types. Two variants:

Linear regression (Polynomial, Logarithmic, Custom Linear):

  • Method: LinearLeastSquares (read-only)

  • TolCon (editable; has no effect without constraint points, which require Optimization Toolbox) (R2025a+)

  • Coefficients table: Coefficient Name (read-only), Lower Bound, Upper Bound

  • Constraint Points to Fit Through: table with Add/Delete buttons (2D for curves, 3D for surfaces) (R2025a+)

Nonlinear regression (Exponential, Fourier, Gaussian, Power, Rational, Sum of Sine, Weibull, Sigmoidal, Custom Equation):

  • Method: NonlinearLeastSquares (read-only)

  • Robust dropdown: Off, LAR, Bisquare

  • Algorithm dropdown: Trust-Region, Levenberg-Marquardt, Interior-Point (R2025a+, requires Optimization Toolbox) (disabled when constraint points are set)

  • DiffMinChange, DiffMaxChange (editable)

  • MaxFunEvals, MaxIter (editable)

  • TolFun, TolX, TolCon (editable; TolCon has no effect without constraint points, which require Optimization Toolbox) — TolCon (R2025a+)

  • Coefficients table: Coefficient Name (read-only), Start Point, Lower Bound, Upper Bound

  • Constraint Points to Fit Through: table with Add/Delete buttons (2D for curves, 3D for surfaces) (R2025a+)

Coefficient names in the Advanced Options table are always read-only — determined by the fit type. For Custom Equation, coefficients are automatically extracted from the equation text. For Custom Linear, coefficient names and term expressions are editable in the main panel's table above.

"Read about fit options" hyperlink at the bottom (opens Help browser).


Results Panel

R2023a+: The Results panel was redesigned and the copy button was added. In R2022a–R2022b, results were displayed in a large text area (selectable for manual copying, but not messages) with most of the same information, and messages appeared above it rather than inline.

Located in the lower-right side panel, below Fit Options. Contains a copy button that copies the results text to the clipboard.

Contents (when a fit is computed)
  1. Fit Name — displayed name of the selected fit

  2. Fit description — e.g., "Polynomial Curve Fit (poly1)" or "Exponential Curve Fit (exp1)" or "Interpolating Surface Fit (linearinterp)"

  3. Formula — e.g., f(x) = p1*x + p2 or f(x,y) = piecewise linear surface with no extrapolation

  4. Normalization info (if Center and scale is enabled) — shows mean and std for each variable

  5. Coefficients and 95% Confidence Bounds — table with columns: Value, Lower, Upper; rows for each coefficient

  6. Goodness of Fit — table with columns: Value; rows: SSE, R-square, DFE, Adj R-sq, RMSE

  7. Goodness of Validation — same metrics computed against validation data (shown only when validation data is assigned)

When no fit is computed (e.g., no data assigned), only the Fit Name is shown.

The Results panel may also display info, warning, or error messages (e.g., data issues, instructions to click Fit in manual mode, fit convergence warnings).


Table of Fits

Located at the bottom of the app. Shows one row per fit in the session.

Columns
  • Fit State — icon indicator (see below)

  • Fit Name — display name of the fit (editable by double-clicking the cell)

  • Data — e.g., "y vs. x" or "z vs. x, y"

  • Fit Type — e.g., "poly1", "exp1", "linearinterp", or custom equation text

  • R-square

  • SSE

  • DFE

  • Adj R-sq

  • RMSE

  • Num Coefficients

  • Validation Data — validation data description (if assigned)

  • Validation SSE

  • Validation RMSE

Fit State icons:

  • Green checkmark — fit completed without any warnings or errors

  • Yellow warning — fit completed, but at least one warning was thrown (may or may not require attention)

  • Red error — an error was thrown somewhere in the workflow

  • No icon — missing fitting data, or fit needs to be executed (manual mode)

Interactions
  • Click a row — selects that fit and switches the figure tab, Fit Options, and Results to show it

  • Right-click a row — context menu with:

    • Duplicate "[fit name]"

    • Delete "[fit name]"

    • Save "[fit name]" to Workspace...


Fit Figure Area

The center of the app shows the fit figures in a tabbed layout. Each fit has its own figure. The currently displayed/selected fit is the one that toolstrip controls, Fit Options, and Results apply to. All plots (Fit Plot, Residuals Plot, Contour Plot) are toggled via the Visualization section in the toolstrip.

Tabs
  • Each figure tab shows the fit name with a close (x) button

  • Tab bar supports the actions menu (three dots button, left of tabs) with:

    • Maximize (Ctrl+Shift+M)

    • Close All Except [fit name]

    • Close All to the Right

    • Close All

    • Close Fits

    • Tile All

    • Sub-Tile Fits

    • Tab Position (submenu: Top, Left, Bottom, Right — controls where tabs are rendered)

  • "Close All Except", "Close All to the Right", "Close All", "Close Fits", "Tile All", and "Sub-Tile Fits" only appear when more than one fit is present

  • Tile All / Sub-Tile Fits arrange figures side-by-side for visual comparison

  • Figures can also be tiled by clicking and dragging a tab to dock it beside another

  • Closing a tab does not delete the fit — it remains in the Table of Fits. Reselect it in the Table of Fits to reopen the figure. If all figure tabs are closed, toolstrip controls and side panels will be empty/disabled until a fit is reselected.

Fit Plot
  • Curve fits: 2D scatter plot of data points with the fitted curve overlaid. Legend shows fitting data, validation data (if assigned), excluded points, and the fitted curve.

  • Surface fits: 3D surface mesh plot with data points shown as markers. Legend shows fitting data, validation data (if assigned), and excluded points (not the surface mesh).

Residuals Plot
  • Curve fits: 2D stem plot of residuals (vertical lines from zero line to each residual value)

  • Surface fits: 3D stem plot of residuals (vertical lines from a plane at z = 0 to each residual value)

Contour Plot (surface fits only)
  • Shows 2D contour map of the fitted surface

  • Data points shown as markers on the contour

Multi-Plot Layout
  • One plot visible: fills the entire figure area

  • Two plots visible: stacked vertically (top/bottom)

  • Three plots visible (surface fits only): contour plot on the left half; fit plot and residuals plot stacked vertically on the right half

Axes Toolbar

Hovering over a plot reveals a toolbar with custom actions (left to right):

ToolAction
LegendShow/hide the plot legend
GridShow/hide grid lines
Exclude outliersClick individual points or drag a bounding box to toggle exclusion of data points
Data cursorClick points to show coordinate values
PanClick and drag to pan the view
Zoom inClick and drag to zoom in
ZoomClick to zoom out
Restore viewRestore the original axis limits

The "Exclude outliers" tool is the primary interactive method for manually excluding outliers and can also be referred to as manual/interactive exclusions.


Copyright 2026 The MathWorks, Inc.


Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

What our scanner noticed· Low risk

  • Phrasing that asks for actions without confirmation

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
MathWorks
Publisher
MathWorks (Official)
Source
matlab/matlab-agentic-toolkit · skills-catalog/ai-and-statistics/matlab-fit-curve · commit 2a7f215
Licence
BSD 2-Clause License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.md)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by MathWorks or MathWorks.

Get it from the source

2 of this skill’s files are not mirrored here, so there is no ZIP. Get the complete skill from its source: matlab/matlab-agentic-toolkit