|MATLAB Function Reference|
Remove linear trends.
detrend removes the mean value or linear trend from a vector or matrix, usually for FFT processing.
removes the best straight-line fit from vector
y = detrend(x)
x and returns it in
x is a matrix,
detrend removes the trend from each column.
removes the mean value from vector
y = detrend(x,'constant'
x or, if
x is a matrix, from each column of the matrix.
removes a continuous, piecewise linear trend from vector
y = detrend(x,'linear',bp
x or, if
x is a matrix, from each column of the matrix. Vector
bp contains the indices of the breakpoints between adjacent linear segments. The breakpoint between two segments is defined as the data point that the two segments share.
detrend(x,'linear'), with no breakpoint vector specified, is the same as
Note that the breakpoint is specified to be the fifth element, which is the data point shared by the two segments.
detrend computes the least-squares fit of a straight line (or composite line for piecewise linear trends) to the data and subtracts the resulting function from the data. To obtain the equation of the straight-line fit, use