| Contents | Index |
data_d = detrend(data)
data_d = detrend(data,Type)
[data_d,T] = detrend(data,Type)
data_d = detrend(data,1,brkp)
data_d = detrend(data) subtracts the mean value from each time-domain or time-series signal data. data_d and data are iddata objects.
data_d = detrend(data,Type) subtracts a mean value from each signal when Type = 0, a linear trend (least-squares fit) when Type = 1, or a trend specified by a TrendInfo object when Type = T.
[data_d,T] = detrend(data,Type) stores the trend information as a TrendInfo object T.
data_d = detrend(data,1,brkp) subtracts a piecewise linear trend at one or more breakpoints brkp. brkp is a data index where discontinuities between successive linear trends occur. When brkp contains breakpoints that match the time vector, detrend subtracts a continuous piecewise linear trend. You cannot store piecewise linear trend information as an output argument.
Subtract mean values from input and output signals and store the trend information:
% Load SISO data containing vectors u2 and y2. load dryer2 % Create data object with sampling interval of 0.08 sec. data=iddata(y2,u2,0.08) % Plot data on a time plot. Data has a nonzero mean. plot(data) % Remove the mean from the data. [data_d,T] = detrend(data,0) % Plot detrended data on the same plot. hold on plot(data_d)
Remove specified offset from input and output signals:
% Load SISO data containing vectors u2 and y2. load dryer2 % Create data object with sampling time of 0.08 sec. data=iddata(y2,u2,0.08) plot(data) % Create a TrendInfo object for storing offsets and trends. T = getTrend(data) % Assign offset values to the TrendInfo object. T.InputOffset=5; T.OutputOffset=5; % Subtract offset from the data. data_d = detrend(data,T) % Plot detrended data on the same plot. hold on plot(data_d)
Subtract several linear trends that connect at three breakpoints [30 60 90]:
data = detrend(data,1,[30 60 90]); % [30 60 90] are data indexes where breakpoints occur.
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];

Learn more about resources for designing, testing, and implementing control systems.
Get free kit| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |