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 aniddata
object. SeeRepresenting 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 thedetrend
command to remove the signal means or linear trends:
[data_d,T]=detrend(data,Type)
wheredata
is the data to be detrended. The second input argumentType=0
removes signal means orType=1
removes linear trends.data_d
is the detrended data.T
is aTrendInfo
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
iddata
object. SeeRepresenting 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, seeHow 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
T
is aTrendInfo
object.Assign offset values to
T
.T.InputOffset=I_value; T.OutputOffset=O_value;
where
I_value
is the input offset value, andO_value
is the input offset value.Remove the specified offsets from
data
.data_d = detrend(data,T)
where the second input argument
T
stores the offset values as its properties.