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

    %% 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.
hsin = dsp.SineWave('Frequency',10,...
    'ComplexOutput',true,'SamplesPerFrame',128);

%%
% Create a |dsp.PhaseExtractor| System object(TM). Specify that the object 
% ignores frame boundaries when returning the unwrapped phase.
hphase = dsp.PhaseExtractor('TreatFramesIndependently',false);

%%
% Extract the unwrapped phase of a sine wave. Plot the phase versus time
% using a |dsp.TimeScope| System object(TM).
hplot = dsp.TimeScope('PlotType','Line','SampleRate',1000,...
    'TimeSpan',1.5,'YLimits',[0 80],...
    'ShowGrid',true,...
    'YLabel','Unwrapped Phase (rad)');
for ii = 1:10
    sineOutput = hsin();
    phaseOutput = hphase(sineOutput);
    hplot(phaseOutput)
end