This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Class: timeseries

Subtract mean or best-fit line and all NaNs from timeseries object


ts1 = detrend(ts, method)
ts1 = detrend(ts, method, index)


ts1 = detrend(ts, method) subtracts either a mean or a best-fit line from time-series data, using the specified method. Usually for FFT processing.

ts1 = detrend(ts, method, index) uses the optional index to specify the columns or rows to detrend.

Input Arguments


The timeseries object from which you want to subtract the mean or best-fit line and all NaNs.


A string that specifies one of the following detrend methods:

  • 'constant' — Subtracts the mean.

  • 'linear' — Subtracts the best-fit line.


An integer array that specifies the columns or rows to detrend when ts.IsTimeFirst is true.

Output Arguments


The timeseries object resulting from detrending the input timeseries object.


  • You cannot apply detrend totimeseries data with more than two dimensions.

See Also

Introduced before R2006a

Was this topic helpful?