Skip to content
MathWorks - Mobile View
  • Sign In to Your MathWorks AccountSign In to Your MathWorks Account
  • Access your MathWorks Account
    • My Account
    • My Community Profile
    • Link License
    • Sign Out
  • Products
  • Solutions
  • Academia
  • Support
  • Community
  • Events
  • Get MATLAB
MathWorks
  • Products
  • Solutions
  • Academia
  • Support
  • Community
  • Events
  • Get MATLAB
  • Sign In to Your MathWorks AccountSign In to Your MathWorks Account
  • Access your MathWorks Account
    • My Account
    • My Community Profile
    • Link License
    • Sign Out

Videos and Webinars

  • MathWorks
  • Videos
  • Videos Home
  • Search
  • Videos Home
  • Search
  • Contact sales
  • Trial software
3:18 Video length is 3:18.
  • Description
  • Full Transcript
  • Related Resources

How to Perform Curve Fitting Using the Curve Fitting App in MATLAB

Learn how to perform curve fitting in MATLAB® using the Curve Fitting app and fit noisy data using smoothing spline. You can use the Curve Fitting app interactively to try a variety of fitting algorithms, assess the fit numerically, and generate code from the app.

In this video, we will show you how to perform curve fitting in MATLAB for math modeling applications. Curve fitting is the process of constructing a curve or mathematical function that has the best fit to a series of data points. In a way, summarize the relationship among these variables.

In this video, we will see interactive curve fitting using the curve fitting app. Before you can fit data, you need to load the data variables into the MATLAB workspace. For this example, we load some basic US population data that is available in MATLAB at census.mat.

We can see the workspace has the variables cdate and pop. Pop is the population that corresponds to the years in cdate. We now create a basic plot of the two variables.

We can open the curve fitting tool by clicking on the Apps tab and selecting Curve Fitting or by typing CF Tool and then running the section. To load cdate and pop into the curve fitting tool, select them as x data and y data, respectively.

The default effort is a linear polynomial fit of degree 1. The curve fitting app allows you to explore many different functions, including Exponential, Fourier, and Power to name a few. And you can evaluate their goodness of fit.

For example, change the fit to a second-degree polynomial by selecting 2 from the degree list and observe how much the fit improves both visually and in the Goodness of Fit measures like sum of squared arrow. The Curve Fitting toolbox has functions that allow you to construct splines for fitting to and smoothing data.

If your data is noisy, you might want to fit it using a smoothing spline. Splines are smooth piecewise polynomials that can be used to represent functions over large intervals, but it would be impractical to use a single approximating polynomial.

Let us load carbon-12 alpha into the workspace. In the curve fitting app, load Angle and Counts. Select them as x and y data, respectively. Select the smoothing spline fit type.

The toolbox attempts to select a default value appropriate for your data. The default smoothing parameter produces the smoothest curve. To make a smoother fit further from the data, click the Smoother button repeatedly until the plot shows the smoothness you want.

Similarly, to make a ruffle closer to the data, click the Ruffle button until you are satisfied with the plot. Click Default to return to the initial value. The app keeps track of the various fits you tried. Select File, click Generate Code to create a MATLAB function to recreate all fits and plots in your interactive session.

In conclusion, we discussed how to perform curve fitting in MATLAB using the curve fitting app and fitting noisy data using smoothing spline. The curve fitting app helps you try a variety of algorithms interactively, assess the fit numerically and visually, and generate code from the app. If you want to learn more about the curve fitting toolbox and its functionalities that we used in this video, feel free to go through the links in the description.

Related Products

  • MATLAB
  • Curve Fitting Toolbox

3 Ways to Speed Up Model Predictive Controllers

Read white paper

A Practical Guide to Deep Learning: From Data to Deployment

Read ebook

Bridging Wireless Communications Design and Testing with MATLAB

Read white paper

Deep Learning and Traditional Machine Learning: Choosing the Right Approach

Read ebook

Hardware-in-the-Loop Testing for Power Electronics Control Design

Read white paper

Predictive Maintenance with MATLAB

Read ebook

Electric Vehicle Modeling and Simulation - Architecture to Deployment : Webinar Series

Register for Free

How much do you know about power conversion control?

Start quiz

Feedback

Featured Product

MATLAB

  • Request Trial
  • Get Pricing

Up Next:

3:14
Importing Excel Data and Fitting a Curve to It

Related Videos:

39:07
MATLAB Meets MINDSTORMS: How to Control LEGO NXT Robots...
23:51
How Weather and Pricing Affect Sales: Using MATLAB to...
30:55
How Fennia Life Models Insurance Risk for Solvency II,...
2:42
Agilent Oscilloscopes: Using ScopeMath App

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

  • Switzerland (English)
  • Switzerland (Deutsch)
  • Switzerland (Français)
  • 中国 (简体中文)
  • 中国 (English)

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Contact sales
  • Trial software

MathWorks

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Discover…

Explore Products

  • MATLAB
  • Simulink
  • Student Software
  • Hardware Support
  • File Exchange

Try or Buy

  • Downloads
  • Trial Software
  • Contact Sales
  • Pricing and Licensing
  • How to Buy

Learn to Use

  • Documentation
  • Tutorials
  • Examples
  • Videos and Webinars
  • Training

Get Support

  • Installation Help
  • MATLAB Answers
  • Consulting
  • License Center
  • Contact Support

About MathWorks

  • Careers
  • Newsroom
  • Social Mission
  • Customer Stories
  • About MathWorks
  • Select a Web Site United States
  • Trust Center
  • Trademarks
  • Privacy Policy
  • Preventing Piracy
  • Application Status

© 1994-2022 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Join the conversation