FUNCTION REFERENCE

smoothdata

Smooth noisy data.

Smooth noisy data.

Syntax

B = smoothdata(A)

Syntax

B = smoothdata(A, dim)

Syntax

B = smoothdata(..., method)

Syntax

B = smoothdata(..., method, window)

Syntax

B = smoothdata(..., nanflag)

Syntax

B = smoothdata(..., 'SmoothingFactor', f)

Syntax

B = smoothdata(..., 'sgolay', window, 'Degree', d)

Syntax

[B, window] = smoothdata(...)

Smooths each vector along dim (default: the first dimension whose size is not 1). Methods: 'movmean' (default, moving mean), 'movmedian' (moving median), 'gaussian' (Gaussian-weighted moving mean with standard deviation window/5), 'lowess' and 'loess' (local linear and quadratic least squares fits with tricube weights (1-(|t|/d)^3)^3, where d is one more than the largest offset t in the window), 'rlowess' and 'rloess' (the same followed by five robustness passes that weight each sample by the bisquare of its residual over six median absolute residuals, stopping early when that median is 0; residuals below 1e-12 times the largest magnitude count as 0), and 'sgolay' (unweighted local polynomial fit of degree 'Degree', default 2, which must be less than the window length). A scalar window k centers each window, with one extra sample behind for even k; [kb kf] gives the samples before and after. Windows shrink at the ends. 'omitnan' (default) skips NaN values; 'includenan' gives NaN for every window that holds a NaN. Without a window, the window is the smallest moving-mean length k whose frequency response removes at least the fraction f (default 0.25) of the energy of the mean-removed data (pooled over all vectors, NaN counted as the mean); every k from 1 up is tried, because the removed energy does not grow steadily with k (alternating data loses all of it at k = 2 but not at k = 3). For 'sgolay' it is at least Degree+1. The second output is the window used (double). Single input gives a single result; integer input gives a double result (the published page does not state the class).

Example

smoothdata([1 5 2 8 3], 'movmean', 3)   % [3 2.6667 5 4.3333 5.5]

Example

[b, w] = smoothdata([1 5 2 8 3 9 4], 'movmedian', 3)   % w = 3

Example

smoothdata([1 2 3 4 20 6 7], 'rlowess', 5)

Differences from MATLAB: MATLAB does not publish its default window algorithm or its local-regression weights and robustness iterations, so default windows and the lowess, loess, rlowess, rloess and gaussian results can differ from MATLAB's. No 'SamplePoints', non-integer windows, tables or N-D arrays.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.