This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

dsp.CrossSpectrumEstimator System object

Estimate cross-spectral density


The dsp.CrossSpectrumEstimator computes the cross- spectrum density of a signal, using the Welch algorithm and the Periodogram method.

To implement the cross-spectrum estimation object:

  1. Define and set up your cross-spectrum estimator object. See Construction.

  2. 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.


Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.


cse = dsp.CrossSpectrumEstimator returns a System object, cse, that computes the cross-power spectrum of real or complex signals using the periodogram method and Welch’s averaged, modified periodogram method.

cse = dsp.CrossSpectrumEstimator('PropertyName', PropertyValue,...) returns a Cross-Spectrum Estimator System object, cse, 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.


Number of spectral averages

Specify the number of spectral averages as a positive, integer scalar. The Cross-Spectrum Estimator computes the current cross-spectral estimate by averaging the last N estimates. N is the number of spectral averages defined in the SpectralAverages property. The default is 8.


Source of the FFT length value

Specify the source of the FFT length value as one of 'Auto' | 'Property'. The default is 'Auto'. If you set this property to 'Auto', the Cross-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.


FFT Length

Specify the length of the FFT that the Cross-Spectrum Estimator uses to compute cross-spectral estimates as a positive, integer scalar. This property applies when you set the FFTLengthSource property to 'Property'. The default value is 128.


Window function

Specify a window function for the cross-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 is 60 dB.


Frequency range of the cross-spectrum estimate

Specify the frequency range of the cross-spectrum estimator as one of 'twosided' | 'onesided' | 'centered'.

If you set the FrequencyRange to 'onesided', the cross-spectrum estimator computes the onesided spectrum of real input signals, x and y. If the FFT length, NFFT, is even, the length of the cross-spectrum estimate is NFFT/2+1 and is computed over the interval [0,SampleRate/2]. If NFFT is odd, the length of the cross-spectrum estimate is equal to (NFFT+1)/2 and the interval is [0,SampleRate/2].

If you set the FrequencyRange to 'twosided', the cross-spectrum estimator computes the twosided spectrum of complex or real input signals, x and y. The length of the cross-spectrum estimate is equal to NFFT. This value is computed over [0, SampleRate].

If you set the FrequencyRange to 'centered', the cross-spectrum estimator computes the centered twosided spectrum of complex or real input signals, x and y. The length of the cross-spectrum estimate is equal to NFFT and it is computed between [-SampleRate/2, SampleRate/2] and (-SampleRate/2, SampleRate/2) for even and odd lengths, respectively. The default value is 'Twosided'.


getFrequencyVectorGet the vector of frequencies at which the cross-spectrum is estimated
getRBWGet the resolution bandwidth of the cross-spectrum
resetReset the internal states of the cross-spectrum estimator
stepEstimate the cross-spectrum of a signal
Common to All System Objects

Allow System object property value changes


expand all

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).

Generate two sine waves.

sin1 = dsp.SineWave('Frequency',200, 'SampleRate', 1000);
sin1.SamplesPerFrame = 1000;
sin2 = dsp.SineWave('Frequency',100, 'SampleRate', 1000);
sin2.SamplesPerFrame =  1000;

Use the Cross-Spectrum Estimator to compute the cross-spectrum of the signals. Also, use the Array Plot to display the spectra.

cse = dsp.CrossSpectrumEstimator('SampleRate', sin1.SampleRate,...
aplot = 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. Stream in the data, and plot the cross-power spectrum of the two signals.

for ii = 1:10
x = sin1() + 0.05*randn(1000,1);
y = sin2() + 0.05*randn(1000,1);
Pxy = cse(x, y);


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.

Extended Capabilities

Introduced in R2013b