Estimate power spectrum
The dsp.SpectrumEstimator computes the power spectrum of a signal, using the Welch algorithm and the Periodogram method.
To implement the spectrum estimation object:
H = dsp.SpectrumEstimator returns a System object™, H, that computes the frequency power spectrum of real or complex signals. This System object uses the periodogram method and Welch's averaged, modified periodogram method.
H = dsp.SpectrumEstimator('PropertyName', PropertyValue,...) returns a Spectrum Estimator System object, H, with each specified property name set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).
Sample rate of input
Specify the sample rate of the input in, hertz, as a finite numeric scalar. The default value is 1 Hz. The sample rate is the rate at which the signal is sampled in time.
Specify the spectrum type as one of 'Power' | 'Power density'. When the spectrum type is 'Power', the power spectral density is scaled by the equivalent noise bandwidth of the window (in Hz). The default value is 'Power'. This property is tunable.
Number of spectral averages
Specify the number of spectral averages as a positive, integer scalar. The Spectrum Estimator computes the current power spectrum estimate by averaging the last N estimates. N is the number of spectral averages defined in the SpectralAverages property. The default value is 8.
Source of the FFT length value
Specify the source of the FFT length value as one of 'Auto' | 'Property'. The default value is 'Auto'. If you set this property to 'Auto', the Spectrum Estimator sets the FFT length to the input frame size. If you set this property to 'Property', then you specify the number of FFT points using the FFTLength property.
Specify the length of the FFT that the Spectrum Estimator uses to compute spectral estimates as a positive, integer scalar. This property applies when you set the FFTLengthSource property to 'Property'. The default value is 128.
Specify a window function for the spectral estimator as one of 'Rectangular' | 'Chebyshev' | 'Flat Top' | 'Hamming' | 'Hann' | 'Kaiser'. The default value is 'Hann'.
Side lobe attenuation of window
Specify the side lobe attenuation of the window as a real, positive scalar, in decibels (dB). This property applies when you set the Window property to 'Chebyshev' or 'Kaiser'. The default value is 60 dB.
Frequency range of the spectrum estimate
Specify the frequency range of the spectrum estimator as one of 'twosided' | 'onesided' | 'centered'.
If you set the FrequencyRange to 'onesided', the spectrum estimator computes the onesided spectrum of real input signals, x and y. If the FFT length, NFFT, is even, the length of the spectrum estimate is NFFT/2+1, and is computed over the interval [0,SampleRate/2]. If NFFT is odd, the length of the spectrum estimate is equal to (NFFT+1)/2 and the interval is [0,SampleRate/2).
If you set the FrequencyRange to 'twosided', the spectrum estimator computes the twosided spectrum of complex or real input signals, x and y. The length of the spectrum estimate is equal to NFFT, and is computed over [0, SampleRate).
If you set the FrequencyRange to 'centered', the spectrum estimator computes the centered twosided spectrum of complex or real input signals, x and y. The length of the spectrum estimate is equal to NFFT. This value is computed over (-SampleRate/2, SampleRate/2] for even lengths, and (-SampleRate/2, SampleRate/2) for odd lengths. The default value is 'twosided'.
|clone||Create spectrum estimator object with same property values|
|getFrequencyVector||Get the vector of frequencies at which the spectrum is estimated|
|getRBW||Get the resolution bandwidth of the spectrum|
|isLocked||Locked status for input attributes and nontunable properties|
|reset||Reset the internal states of the spectrum estimator|
|step||Estimate the frequency spectrum of a signal|
Compute the power spectrum of a noisy sine wave
Generate a sine wave:
hsin = dsp.SineWave('Frequency',100, 'SampleRate', 1000); hsin.SamplesPerFrame = 1000;
Use the Spectrum Estimator to compute the power spectrum of the sine wave. Also, use the Array Plot to display the spectrum:
hs = dsp.SpectrumEstimator('SampleRate', hsin.SampleRate,... 'SpectrumType','Power',... 'FrequencyRange','centered'); hplot = dsp.ArrayPlot('PlotType','Line','XOffset',-500,'YLimits',... [0 .35],'YLabel','Power Spectrum (Watts)',... 'XLabel','Frequency (Hz)',... 'Title','Power Spectrum of 100 Hz Sine Wave');
Add random noise to the sine wave. Step through the System objects to obtain the data streams, and plot the power spectrum of the signal:
for ii = 1:10 x = step(hsin) + 0.05*randn(1000,1); Pxx = step(hs, x); step(hplot,Pxx); end
Let x be the input frame. We first multiply x by the window, and scale it by the window power. We then take FFT of the signal, calling it Y. This is followed by taking the square magnitude of the FFT, i.e., Z = Y*conj(Y). We average the last N number of Z's, and scale the answer by the sample rate.
For further information refer to the Algorithms section in Spectrum Analyzer, which uses the same algorithm.
 Hayes, Monson H. Statistical Digital Signal Processing and Modeling. Hoboken, NJ: John Wiley & Sons, 1996
 Kay, Steven M. Modern Spectral Estimation: Theory and Application. Englewood Cliffs, NJ: Prentice Hall, 1999
 Stoica, Petre and Randolph L. Moses. Spectral Analysis of Signals. Englewood Cliffs, NJ: Prentice Hall, 2005
 Welch, P. D. ``The use of fast Fourier transforms for the estimation of power spectra: A method based on time averaging over short modified periodograms,'' IEEE Transactions on Audio and Electroacoustics, Vol. 15, pp. 70–73, 1967.