Contenuto principale

Detrend

R2026b

Remove linear trend from vectors

  • Detrend block

Libraries:
DSP System Toolbox / Statistics

Description

The Detrend block removes a linear trend from the length-M input vector, u, by subtracting the straight line that best fits the data in the least squares sense.

The least squares line, û = ax + b, is the line with parameters a and b that minimizes the quantity

∑i=1M(ui−u^i)2

for M evenly-spaced values of x, where ui is the ith element in the input vector. The output, y = u-û, is always an M-by-1 column vector.

Ports

Input

expand all

Input data, specified as a vector. The block removes the straight line that best fits the data in the least squares sense.

Data Types: single | double

Output

expand all

Output data, returned as a column vector. The block returns the remaining data after removing the straight line that best fits the data in the least squares sense.

Data Types: single | double

Block Characteristics

Data Types

double | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Programmatic Use: Add Block

To add the block programmatically, use the add_block function with one of these library block paths as the source.

"dspstat3/Detrend"

Example: add_block("dspstat3/Detrend","myModel/myBlock",MakeNameUnique="on")

Extended Capabilities

expand all

Version History

Introduced before R2006a