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

    %% Create a Signal Source
%%
% *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() becomes step(myObject).
%%
% Create a signal source to output one sample at a time.
hsr1 = dsp.SignalSource;
hsr1.Signal = randn(1024, 1);
y1 = zeros(1024,1);
idx = 1;
while(~isDone(hsr1))
    y1(idx) = hsr1();
    idx = idx+1;
end

%%
% Create a signal source to output vectors.
hsr2 = dsp.SignalSource(randn(1024, 1), 128);
y2 = hsr2(); % y2 is a 128-by-1 frame of samples