detrend - Subtract trend from time-domain, frequency-domain, or time-series data signal

Syntax

zd = detrend(z)
zd = detrend(z,o,brkp)

Input

z

Name of iddata object in the MATLAB workspace containing time-domain, frequency-domain, or time-series data.

o

Order of the trend, specified as one of the following values:

brkp

Data sample index that defines the discontinuities between successive linear trends, specified as one of the following types of values:

Description

zd = detrend(z) subtracts the mean value (zeroth-order trend) from each signal in z and returns an iddata object zd. If z is frequency-domain data, the response at frequency 0 is zero.

zd = detrend(z,o,brkp) subtracts the mean value (o = 0) or linear trend (o = 1). You can subtract piecewise linear trends by specifying one or more breakpoints brkp, where a breakpoint is a data sample index (time value) that defines the discontinuities between successive linear trends. When brkp contains breakpoints that match the time vector, detrend subtracts a continuous piecewise linear trend.

Examples

Example 1

In this example, you subtract several linear trends that connect at three breakpoints [30 60 90], which correspond to the data sample indexes data where breakpoints occur.

data = detrend(data,1,[30 60 90]);

Example 2

In this example, you subtract a mean value from the input signal and a V-shaped trend from the output signal, such that the V peak occurs at the breakpoint value of 119.

zd1 = z(:,:,[]); zd2 = z(:,[],:);
zd1(:,1,[]) = detrend(z(:,1,[]),1,119);
zd2(:,[],1) = detrend(z(:,[],1));
zd = [zd1,zd2];

See Also

Subtracting Trends from Signals (Detrending)

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS