Main Content

Smooth Data

Smooth noisy data in the Live Editor

Since R2019b

Description

The Smooth Data task lets you interactively smooth noisy data. The task automatically generates MATLAB® code for your live script.

Using this task, you can:

  • Customize the method for smoothing data in a workspace variable.

  • Adjust parameters to generate less or more smoothing.

  • Visualize the input data compared to the smoothed data.

Smooth Data task in the Live Editor

Open the Task

To add the Smooth Data task to a live script in the MATLAB Editor:

  • On the Live Editor tab, select Task > Smooth Data.

  • In a code block in the script, type a relevant keyword, such as smooth or noisy. Select Smooth Data from the suggested command completions.

Parameters

expand all

This task operates on input data contained in a vector, table, or timetable. The data can be of type single, double, logical, or signed or unsigned integer types such as int64.

For table or timetable input data, to smooth all variables with a supported type, select All supported variables. To smooth all variables of type single or double, or signed or unsigned integer types, select All numeric variables. To choose which supported variables to smooth, select Specified variables.

Specify the smoothing method as one of these options, which operate over local windows of data.

MethodDescription
Moving mean

Moving average. This method is useful for reducing periodic trends in data.

Moving medianMoving median. This method is useful for reducing periodic trends in data when outliers are present.
Gaussian filterGaussian-weighted moving average.
Local linear regression (Lowess)Lowess linear regression. This method can be computationally expensive, but it results in fewer discontinuities.
Local quadratic regression (Loess)Loess quadratic regression. This method is slightly more computationally expensive than local linear regression.
Robust LowessRobust Lowess linear regression. This method is a more computationally expensive version of local linear regression, but it is more robust to outliers.
Robust LoessRobust Loess quadratic regression. This method is a more computationally expensive version of local quadratic regression, but it is more robust to outliers.
Savitzky-Golay polynomial filterSavitzky-Golay polynomial filter, which smooths according to a polynomial of specified degree, and is fitted over each window. This method can be more effective than other methods when the data varies rapidly.

Specify the window type and size for the smoothing method instead of specifying a general smoothing factor.

WindowDescription
CenteredSpecified window length centered about the current point
AsymmetricSpecified window containing the number of elements before the current point and the number of elements after the current point

Window sizes are relative to the X-axis variable units.

Limitations

The Smooth Data task does not support 2-D smoothing windows.

Version History

Introduced in R2019b

expand all