%% Plot Unwrapped Phase Of a Sine Wave
% *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).
% 
% Create a |dsp.SineWave| System object(TM). Specify that the object generates 
% an exponential output with a complex exponent.

sine = dsp.SineWave('Frequency',10,...
    'ComplexOutput',true,'SamplesPerFrame',128);
%% 
% Create a |dsp.PhaseExtractor| System object?. Specify that the object 
% ignores frame boundaries when returning the unwrapped phase.
%%
phase = dsp.PhaseExtractor('TreatFramesIndependently',false);
%% 
% Extract the unwrapped phase of a sine wave. Plot the phase versus time 
% using a |timescope| System object.
%%
timeplot = timescope('PlotType','Line','SampleRate',1000,...
    'TimeSpanSource','Property','TimeSpan',1.5,'YLimits',[0 80],...
    'ShowGrid',true,...
    'YLabel','Unwrapped Phase (rad)');
for ii = 1:10
    sineOutput = sine();
    phaseOutput = phase(sineOutput);
    timeplot(phaseOutput)
end

%% 
% Copyright 2012 The MathWorks, Inc.