Main Content

Remove polynomial trend

`y = detrend(`

removes the
best straight-fit line from the data in `x`

)`x`

.

If

`x`

is a vector, then`detrend`

subtracts the trend from the elements of`x`

.If

`x`

is a matrix, then`detrend`

operates on each column separately, subtracting each trend from the corresponding column.

`y = detrend(___,`

specifies
how `nanflag`

)`NaN`

values are treated for any of the previous syntaxes. For example,
`detrend(x,'omitnan')`

removes `NaN`

values before
calculating the trend, while `detrend(x,'includenan')`

includes them
(default).

`y = detrend(___,`

specifies additional parameters using one or more name-value pairs. For example,
`Name,Value`

)`detrend(x,1,bp,'Continuous',false)`

specifies that the fitted trend can
have discontinuities.