www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/SignalDelayUsingAVariableFractionalDelayExample.m

    %% Signal Delay using a Variable Fractional Delay
%%
% *Note*: This example runs only in R2016b or later. If you are using an
% earlier release, replace each call to the function with the equivalent
% |step| syntax. For example, myObject(x) becomes step(myObject,x).

%%
% Delay a signal by a varying fractional number of sample periods.
hsr = dsp.SignalSource;
hvfd = dsp.VariableFractionalDelay;
hLog = dsp.SignalSink;

for ii = 1:10
    delayedsig = hvfd(hsr(), ii/10);
    hLog(delayedsig);
end

sigd = hLog.Buffer;

%%
% The output |sigd| corresponds to the values of the delayed signal
% that are sampled at fixed-time intervals. For visualization
% purposes, we can instead plot the time instants at which the
% amplitudes of signal samples are constant by treating the
% signals as the sampling instants.

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