Package: dsp
Estimate crossspectral density
The dsp.CrossSpectrumEstimator
computes the
cross spectrum density of a signal, using the Welch algorithm and
the Periodogram method.
To implement the crossspectrum estimation object:
Define and set up your crossspectrum estimator object. See Construction.
Call step
to implement the estimator
according to the properties of dsp.CrossSpectrumEstimator
.
The behavior of step
is specific to each object in
the toolbox.
H = dsp.CrossSpectrumEstimator
returns
a System object™, H, that computes the crosspower spectrum of
real or complex signals using the periodogram method and Welch's
averaged, modified periodogram method.
H = dsp.CrossSpectrumEstimator('
returns
a PropertyName
', PropertyValue
,...)CrossSpectrum Estimator
System object, H,
with each specified property name set to the specified value. You
can specify additional namevalue 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 

Number of spectral averages Specify the number of spectral averages as a positive, integer
scalar. The CrossSpectrum Estimator computes the current crossspectral
estimate by averaging the last 

Source of the FFT length value Specify the source of the FFT length value as one of 

FFT Length Specify the length of the FFT that the CrossSpectrum Estimator
uses to compute crossspectral estimates as a positive, integer scalar.
This property applies when you set the 

Window function Specify a window function for the crossspectral estimator as
one of 

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 

Frequency range of the crossspectrum estimate Specify the frequency range of the crossspectrum estimator
as one of If you set the If you set the If you set the 
clone  Create crossspectrum estimator object with same property values 
getFrequencyVector  Get the vector of frequencies at which the crossspectrum is estimated 
getRBW  Get the resolution bandwidth of the crossspectrum 
isLocked  Locked status for input attributes and nontunable properties 
reset  Reset the internal states of the crossspectrum estimator 
step  Estimate the crossspectrum of a signal 
Compute the crosspower spectrum of two noisy sine waves
Generate two sine waves:
hsin1 = dsp.SineWave('Frequency',200, 'SampleRate', 1000); hsin1.SamplesPerFrame = 1000; hsin2 = dsp.SineWave('Frequency',100, 'SampleRate', 1000); hsin2.SamplesPerFrame = 1000;
Use the CrossSpectrum Estimator to compute the crossspectrum of the signals. Also, use the Array Plot to display the spectra:
hs = dsp.CrossSpectrumEstimator('SampleRate', hsin1.SampleRate,... 'FrequencyRange','centered'); hplot = dsp.ArrayPlot('PlotType','Line','XOffset',500,'YLimits',... [150 60],'YLabel','Power Spectrum Density (Watts/Hz)',... 'XLabel','Frequency (Hz)',... 'Title','Cross Power Spectrum of Two Signals');
Add random noise to the sine waves. Step through the System objects to obtain the data streams, and plot the crosspower spectrum of the two signals:
for ii = 1:10 x = step(hsin1) + 0.05*randn(1000,1); y = step(hsin2) + 0.05*randn(1000,1); Pxy = step(hs, x, y); step(hplot,20*log10(abs(Pxy))); end
Given two signals x
and y
as
inputs. We first window the two inputs, and scale them by the window
power. We then take FFT of the signals, calling them X
and Y
.
This is followed by taking the cross correlation of the FFT, i.e., Z
= X*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.
[1] Hayes, Monson H. Statistical Digital Signal Processing and Modeling. Hoboken, NJ: John Wiley & Sons, 1996.
[2] Kay, Steven M. Modern Spectral Estimation: Theory and Application. Englewood Cliffs, NJ: Prentice Hall, 1999.
[3] Stoica, Petre, and Randolph L. Moses. Spectral Analysis of Signals. Englewood Cliffs, NJ: Prentice Hall, 2005.
[4] Welch, P. D. ''The Use of Fast Fourier Transform for the Estimation of Power Spectra: A Method Based on Time Averaging Over Short Modified Periodograms''. IEEE Transactions on Audio and Electroacoustics. Vol. 15, No. 2, June 1967, pp. 70–73.
Cross
Spectrum Estimator  dsp.SpectrumAnalyzer
 dsp.SpectrumEstimator
 dsp.TransferFunctionEstimator