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

    %% Power Spectrum of Multichannel Sinusoidal Signal
% Generate a three-channel sinusoid sampled at 1 kHz. Specify sinusoidal
% frequencies of 100, 200, and 300 Hz. The second and third channels have
% their phases offset from the first by $\pi/2$ and $\pi/4$, respectively.

% Copyright 2015 The MathWorks, Inc.


SINE = dsp.SineWave('SamplesPerFrame',1000,'SampleRate',1000, ...
    'Frequency',[100 200 300],'PhaseOffset',[0 pi/2 pi/4]);

%%
% Estimate and plot the one-sided spectrum of the signal. Use the Spectrum
% Estimator for the computation and the Array Plot for the plotting.

SE = dsp.SpectrumEstimator('FrequencyRange','onesided');
PLOTTER = dsp.ArrayPlot('PlotType','Line','YLimits',[0 0.75], ...
    'YLabel','Power Spectrum (watts)','XLabel','Frequency (Hz)');

%%
% Step through to obtain the data streams and display the spectra of the
% three channels.

y = step(SINE);
pxx = step(SE,y);
step(PLOTTER,pxx)