%% View Sine Wave Input Signals at Different Sample Rates and Offsets
% Create a dsp.SineWave with a 1000 Hz sampling frequency. Create a  dsp.FIRDecimator object to decimate the sine wave by 2. Create a timescope object with two input ports.

Fs = 1000;  % Sampling frequency
sine = dsp.SineWave('Frequency',50,...
   'SampleRate',Fs, ...
   'SamplesPerFrame',100);
decimate = dsp.FIRDecimator; % To decimate sine by 2
scope = timescope(2,[Fs Fs/2], ...
   'TimeDisplayOffset',[0 38/Fs], ...
   'TimeSpanSource','Property',...
   'TimeSpan',0.25, ...
   'YLimits',[-1 1], ...
   'ShowLegend', true);

%
% Call the dsp.SineWave object to create a sine wave signal. Use the dsp.FIRDecimator object to create a second signal that equals the original signal, but decimated by a factor of 2. Display the signals by calling the timescope object.

for ii = 1:2
     xsine = sine();
     xdec = decimate(xsine);
     scope(xsine,xdec)
end
release(scope)

%
% Close the Time Scope window and clear the variables.

clear scope Fs sine decimate ii xsine xdec

% Copyright 2012 The MathWorks, Inc.