y = detrend(x)
y = detrend(x, n)
y = detrend(x, method)
y = detrend(x, n, bp)
| Parameter | Description |
|---|---|
| x | a real vector or matrix. For a matrix, each column is detrended independently. |
| n | trend order: 0 removes the mean, 1 (default) removes a best-fit straight line. |
| method | 'constant' (same as 0) or 'linear' (same as 1). |
| bp | breakpoints given as row indices, producing a continuous piecewise-linear trend. |
| Parameter | Description |
|---|---|
| y | the data with the trend removed, with the same size and class as x. |
detrend removes a low-order polynomial trend from data by a least-squares fit and returns the residual.
By default it removes a straight-line trend. With n equal to 0 (or the method 'constant') it removes only the mean. Breakpoints produce a continuous piecewise-linear trend joined at the given row indices.
A row vector input returns a row vector; a column vector returns a column vector.
t = 0:0.1:2;
x = 3 * t + sin(t);
y = detrend(x)
y = detrend([1 3 2 4 6], 'constant')
| Version | Description |
|---|---|
| 2.0.0 | initial version |