%% Delay Input
% Delay input by five samples by using the dsp.Delay System object™. By default, the initial conditions are 0.
% Note: If you are using R2016a or earlier, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,x).
% Delay input by 4 samples.

delay = dsp.Delay(4);
input = [(1:10)' (11:20)'];
delayOut = delay(input) %#ok
release(delay);

%
% Specify initial conditions for each channel and for each sample. The  InitialConditions property must be a (Length)-by-(NumChannels) matrix.

delay.InitialConditionsPerChannel = true;
delay.InitialConditionsPerSample = true;
delay.InitialConditions = [(0.1:0.1:0.4)' (0.5:0.1:0.8)'];
delayOut = delay(input) %#ok
release(delay);

%
% Reset the delay by setting the reset event to 'Rising edge'. In this mode, a reset event occurs when the reset input:
% Rises from a negative value to 0.
% Rises from a negative value to a positive value.
% Rises form 0 to a positive value, where the rise is not a continuation from a negative value to 0.
% Pass an initial reset input of 0.

delay.ResetInputPort = true;
delay.ResetCondition = 'Rising edge';
delayOut = delay(input,0) %#ok

%
% Continue to run the delay. The delay samples now contain the rest of the input vector.

delayOut = delay(input,0) %#ok

%
% Change the reset input to 2, indicating a rising edge.

delayOut = delay(input,2)

% The delay values are reset to the initial conditions.
% Copyright 2012 The MathWorks, Inc.