How to Detrend Data at the Command Line
Detrending Steady-State Data
Before you can perform this task, you must have time-domain data as an
iddata object. See Representing Time- and Frequency-Domain Data Using iddata Objects.
Note
If you plan to estimate models from this data, your data must be regularly sampled.
Use the detrend command to remove the signal means or linear
trends:
[data_d,T]=detrend(data,Type)
where data is the data to be detrended. The second input argument
Type=0 removes signal means or Type=1 removes linear
trends. data_d is the detrended data. T is a
TrendInfo object that stores the values of the subtracted offsets and
slopes of the removed trends.
Detrending Transient Data
Before you can perform this task, you must have
Time-domain data as an
iddataobject. See Representing Time- and Frequency-Domain Data Using iddata Objects.Note
If you plan to estimate models from this data, your data must be regularly sampled.
Values of the offsets you want to remove from the input and output data. If you do not know these values, visually inspect a time plot of your data. For more information, see How to Plot Data at the Command Line.
Create a default object for storing input-output offsets that you want to remove from the data.
T = getTrend(data)
where
Tis aTrendInfoobject.Assign offset values to
T.T.InputOffset=I_value; T.OutputOffset=O_value;
where
I_valueis the input offset value, andO_valueis the input offset value.Remove the specified offsets from
data.data_d = detrend(data,T)
where the second input argument
Tstores the offset values as its properties.