%% Difference Lag Operator Polynomials
%% Specify a first difference polynomial

D1 = LagOp({1,-1},'Lags',[0,1])

%
%% Specify a monthly differencing polynomial

D12 = LagOp({1,-1},'Lags',[0,12])

%
%% Create second differencing polynomial

D2 = D1*D1

%
%% Simulate data

rng('default')
Y = randn(10,1);

%
%% Filter data through second difference polynomial

Yf = filter(D2,Y);
length(Yf)

%
%% View the indices of the second differenced series

[Yf,Tidx] = filter(D2,Y);
Tidx

%
%% Filter using shorthand syntax

Yf = D2(Y);

% Copyright 2015 The MathWorks, Inc.