%% Signal Delay using Variable Fractional Delay
% 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 fractional number of sample periods.

sr = dsp.SignalSource;
vfd = dsp.VariableFractionalDelay;
sink = dsp.SignalSink;

for ii = 1:10
    delayedsig = vfd(sr(), ii/10);
    sink(delayedsig);
end

sigd = sink.Buffer;

%
% The output sigd corresponds to the values of the delayed signal that are sampled at fixed-time intervals. To plot the time instants at which the amplitudes of signal samples are constant, treat the signals as the sampling instants.

stem(sr.Signal, 1:10, 'b')
hold on;
stem(sigd.', 1:10, 'r');
legend('Original signal', ...
    'Variable fractional delayed signal', ...
    'Location','best')

% Copyright 2012 The MathWorks, Inc.