Pseudospectrum using eigenvector method
implements the eigenvector spectral estimation method and returns
wo] = peig(
the pseudospectrum estimate of the input signal
x, and a vector
wo of normalized frequencies (in rad/sample) at which the
pseudospectrum is evaluated. The pseudospectrum is calculated using estimates of the
eigenvectors of a correlation matrix associated with the input data
x. You can specify the signal subspace dimension using the input
peig(___) with no output arguments plots the
pseudospectrum in the current figure window.
Pseudospectrum of Sum of Sinusoids
Implement the eigenvector method to find the pseudospectrum of the sum of three sinusoids in noise. Use the default FFT length of 256. The inputs are complex sinusoids so you set
p equal to the number of inputs. Use the modified covariance method for the correlation matrix estimate.
n = 0:99; s = exp(1i*pi/2*n)+2*exp(1i*pi/4*n)+exp(1i*pi/3*n)+randn(1,100); X = corrmtx(s,12,'mod'); peig(X,3,'whole')
Pseudospectrum of Real Signal
Generate a real signal that consists of the sum of two sinusoids embedded in white Gaussian noise of unit variance. The signal is sampled at 100 Hz for 1 second. The sinusoids have frequencies of 25 Hz and 35 Hz. The lower-frequency sinusoid has twice the amplitude of the other.
fs = 100; t = 0:1/fs:1-1/fs; s = 2*sin(2*pi*25*t)+sin(2*pi*35*t)+randn(1,100);
Use the eigenvector method to compute the pseudospectrum of the signal between 0 and the Nyquist frequency. Specify a signal subspace dimension of 2 and a DFT length of 512.
It is not possible to resolve the two sinusoids because the signal is real. Repeat the computation using a signal subspace of dimension 4.
x — Input signal
vector | matrix
Input signal, specified as a vector or matrix. If
x is a
vector, then it is treated as one observation of the signal. If
is a matrix, each row of
x represents a separate observation of the
signal. For example, each row is one output of an array of sensors, as in array
processing, such that
x'*x is an estimate of the correlation
You can use the output of
corrmtx to generate
Complex Number Support: Yes
p — Subspace dimension
real positive integer | two-element vector
Subspace dimension, specified as a real positive integer or a two-element vector. If
p is a real positive integer, then it is treated as the subspace
p is a two-element vector, the second element of
p represents a threshold that is multiplied by λmin, the smallest estimated eigenvalue of the signal's correlation matrix.
Eigenvalues below the threshold λmin*
p(2) are assigned to the noise subspace. In this case,
p(1) specifies the maximum dimension of the signal subspace. The extra
threshold parameter in the second entry in
p provides you more
flexibility and control in assigning the noise and signal subspaces.
If the inputs to
peig are real sinusoids, set the value of
p to two times the number of sinusoids. If the inputs are complex
p equal to the number of sinusoids.
Complex Number Support: Yes
wi — Input normalized frequencies
Input normalized frequencies, specified as a vector.
nfft — Number of DFT points
256 (default) | integer | 
Number of DFT points, specified as a positive integer. If
is specified as empty, the default
nfft is used.
fs — Sample rate
1 (default) | positive scalar | 
Sample rate, specified as a positive scalar in Hz. in Hz. If you specify
fs with the empty vector , the sample rate defaults to
fi — Input frequency
Input frequencies, specified as a vector. The pseudospectrum is computed at the frequencies specified in the vector.
nwin — Length of rectangular window
2*p(1) (default) | nonnegative integer
Length of rectangular window, specified as a nonnegative integer.
noverlap — Number of overlapped samples
nwin-1 (default) | nonnegative integer
Number of overlapped samples, specified as a nonnegative integer smaller than the length of window.
noverlap are ignored
when you include
'corr' in the syntax.
freqrange — Frequency range of pseudospectrum estimates
Frequency range of pseudospectrum estimates,specified as one of
'half'— Returns half the spectrum for a real input signal
nfftis even, then
nfft/2 + 1 and is computed over the interval [0, π]. If
nfftis odd, the length of
nfft+ 1)/2 and the frequency interval is [0,π). When your specify
fs, the intervals are [0,
fs/2) and [0,
fs/2] for even and odd
'whole'— Returns the whole spectrum for either real or complex input
x. In this case,
nfftand is computed over the interval [0, 2π). When you specify
fs, the frequency interval is [0,
'centered'— Returns the centered whole spectrum for either real or complex input
x. In this case,
nfftand is computed over the interval (–π, π] for even
nfftand (–π, π) for odd
nfft. When you specify
fs, the frequency intervals are (–
fs/2] and (–
fs/2) for even and odd
You can put the arguments
anywhere in the input argument list after
S — Pseudospectrum estimate
Pseudospectrum estimate, returned as a vector. The pseudospectrum is calculated
using estimates of the eigenvectors of a correlation matrix associated with the input
wo — Output normalized frequencies
Output normalized frequencies, specified as a vector.
wo have the same length. In general, the length of the FFT and
the values of the input
x determine the length of the computed
S and the range of the corresponding normalized frequencies. The
table indicates the length of
the range of the corresponding normalized frequencies for the first syntax.
S Characteristics for an FFT Length of 256 (Default)
|Input Data Type||Length of S and w0||Range of the Corresponding Normalized Frequencies|
nfft is specified, the following table indicates the length
wo and the frequency range for
S and Frequency Vector Characteristics
|Input Data Type||nfft Even or Odd||Length of S and w||Range of w|
Even or odd
fo — Output frequency
Output frequency, returned as a vector. The frequency range for
fo depends on
and the values of the input
x. The length of
fo) is the same as in the S and Frequency Vector Characteristics above. The following table indicates
the frequency range for
fs are specified.
S and Frequency Vector Characteristics with fs Specified
|Input Data Type|
Range of f
Even or odd
also specified, the input data
x is segmented and windowed before
the matrix used to estimate the correlation matrix eigenvalues is formulated. The
segmentation of the data depends on
noverlap, and the form of
x. Comments on the
resulting windowed segments are described in the following table.
Windowed Data Depending on x and nwin
form of x
Form of nwin
Vector of coefficients
Data is not windowed.
Vector of coefficients
See the Eigenvector Length Depending on Input Data and Syntax for related information on this syntax.
v — Noise eigenvector
Noise eigenvectors, returned as a matrix. The columns of
the noise subspace of dimension
size(v,2). The dimension of the
signal subspace is
e — Estimated eigenvalues
Estimated eigenvalues of the correlation matrix, returned as a vector.
The eigenvector method estimates the pseudospectrum from a signal or a correlation matrix
using a weighted version of the MUSIC algorithm derived from Schmidt's eigenspace analysis
. The algorithm performs
eigenspace analysis of the signal's correlation matrix to estimate the signal's frequency
content. If you do not supply the correlation matrix, the eigenvalues and eigenvectors of the
signal's correlation matrix are estimated using
svd. This algorithm is particularly suitable for signals that are the sum of
sinusoids with additive white Gaussian noise.
The eigenvector method produces a pseudospectrum estimate given by
where N is the dimension of the eigenvectors and vkis the kth eigenvector of the correlation matrix of the input signal. The integer p is the dimension of the signal subspace, so the eigenvectors vk used in the sum correspond to the smallest eigenvalues λk of the correlation matrix. The eigenvectors used span the noise subspace. The vector e(f) consists of complex exponentials, so the inner product vkHe(f) amounts to a Fourier transform. This is used for computation of the pseudospectrum. The FFT is computed for each vk and then the squared magnitudes are summed and scaled.
 Marple, S. Lawrence. Digital Spectral Analysis. Englewood Cliffs, NJ: Prentice-Hall, 1987, pp. 373–378.
 Schmidt, R. O. “Multiple Emitter Location and Signal Parameter Estimation.” IEEE® Transactions on Antennas and Propagation. Vol. AP-34, March, 1986, pp. 276–280.
 Stoica, Petre, and Randolph L. Moses. Spectral Analysis of Signals. Upper Saddle River, NJ: Prentice Hall, 2005.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
nwin is variable-size during code
generation, then it must not reduce to a scalar or an empty array at runtime.
Introduced before R2006a