%% Delay a Signal with VariableIntegerDelay Object
% Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes  step(obj,x).
% Delay a signal by a varying number of integer sample periods.

vid = dsp.VariableIntegerDelay;

yout = zeros(100,1);
x    = (1:100).';

for k=1:10
   range       = (k-1)*10+1:k*10;
   yout(range) = vid(x(range),k);
end

stem(x,'b')
hold on; 
stem(yout,'r')
legend('Original Signal', 'Variable Integer Delayed Signal')

% Copyright 2012 The MathWorks, Inc.