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

    %% Delay a Signal with VariableIntegerDelay Object
%%
% *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 number of integer sample periods.
h = dsp.VariableIntegerDelay;
x = 1:100;
ii = 0;
k = 0;
yout = [];

while(ii+10 <= 100)
     y = step(h, x(ii+1:ii+10)',k*ones(10,1));
     yout = [yout;y];
     ii = ii+10;
     k = k+1;
end

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