%% Discontinuous Linear Trend
% Create a vector of data, and remove the piecewise linear trend using a break point at 0. Specify that the resulting output can be discontinuous. Plot the original data, the detrended data, and the trend.

t = -10:10;
x = t.^3 + 6*t.^2 + 4*t + 3;
bp = 0;
y = detrend(x,1,bp,'SamplePoints',t,'Continuous',false);
plot(t,x,t,y,t,x-y,':k')
legend('Input Data','Detrended Data','Trend','Location','northwest') 

% Copyright 2018 The MathWorks, Inc.