www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/AveragedPowerSpectrumOfPinkNoiseExample.m
%% Averaged Power Spectrum of Pink Noise %% % *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 |dsp.ColoredNoise| System object(TM), myObject() % becomes step(myObject). For all other objects, myObject(x) becomes % step(myObject,x). %% % This example shows how to generate two-channels of pink noise and compute % the power spectrum based on a running average of 50 PSD estimates. %% % Set up the colored noise generator to generate two-channels of pink noise % with 1024 samples. Set up the spectrum analyzer to compute modified % periodograms using a Hamming window and 50% overlap. Obtain a running % average of the PSD using 50 spectral averages. Hpink = dsp.ColoredNoise(1,1024,2); Hsa = dsp.SpectrumAnalyzer('SpectrumType','Power density', ... 'OverlapPercent',50,'Window','Hamming', ... 'SpectralAverages',50,'PlotAsTwoSidedSpectrum',false, ... 'FrequencyScale','log','YLimits',[-50 20]); %% % Run the simulation for 30 seconds. tic while toc < 30 pink = Hpink(); Hsa(pink); end