| Signal Processing Toolbox | Search  Help Desk |
| pyulear | Examples See Also |
Power spectrum estimate using Yule-Walker AR method.
Syntax
Pxx = pyulear(x,p,nfft)
[Pxx,freq] = pyulear(x,p,nfft)
[Pxx,freq] = pyulear(x,p,nfft,Fs)
[Pxx,freq] = pyulear(x,p,nfft,Fs,'range')
pyulear(...)
pyulear(...,'squared')
Description
pyulear estimates the power spectral density (PSD) of the signal vector x[n] using the Yule-Walker AR method. This method, also called the autocorrelation method, fits an autoregressive (AR) model to the signal by minimizing the forward prediction error in the least-squares sense. This formulation leads to the Yule-Walker equations, which are solved by the Levinson-Durbin recursion. The spectral estimate returned bypyulear is the magnitude squared frequency response of this AR model. The correct choice of the model order p is important.
Pxx = pyulear(x,p,nfft)
returns Pxx, the power spectrum estimate. x is the input signal, p is the model order for the all-pole filter, and nfft is the FFT length (defaults to 256 if not specified). Pxx has length (nfft/2+1) for nfft even, (nfft+1)/2 for nfft odd, and nfft if x is complex.
[Pxx,freq] = pyulear(x,p,nfft)
returns Pxx, the power spectrum estimate, and freq, a vector of frequencies at which the PSD was estimated. If the input signal is real-valued, the range of freq is [0,
]. If the input signal is complex, the range of freq is [0,2
].
[Pxx,freq] = pyulear(x,p,nfft,Fs)
uses the signal's sampling frequency, Fs, to scale both the PSD vector (Pxx) and the frequency vector (freq). Pxx is scaled by 1/Fs. If the input signal is real-valued, the range of freq is [0,Fs/2]. If the input signal is complex, the range of freq is [0,Fs]. Fs defaults to 1 if left empty, [].
[Pxx,freq] = pyulear(x,p,nfft,Fs,'range')
specifies the range of frequency values to include in freq. range can be:
half, to compute the PSD over the range [0,Fs/2] for real x, and [0,Fs] for complex x. If Fs is left blank, [], the range is [0,1/2] for real x, and [0,1] for complex x. If Fs is omitted entirely, the range is [0,pi] for real x, and [0,2*pi] for complex x. half is the default range.
whole, to compute the PSD over the range [0,Fs] for all x. If Fs is left blank, [], the range is [0,1] for all x. If Fs is omitted entirely, the range is [0,2*pi] for all x.
pyulear(...)
plots the power spectral density in the first available figure window. The frequency range on the plot is the same as the range of output freq for a given set of parameters.
pyulear(...,'squared')
plots the PSD directly, rather than comnverting the values to dB.
Example
Since the method estimates the spectrum by fitting an AR model to the signal, first define the AR system (all-pole filter) that generates the input. Check the magnitude response of the process withfreqz.
a = [1 -2.2137 2.9403 -2.1697 0.9606]; % AR system coefficients
freqz(1,a,'phase','no') % AR system magnitude response
title('AR System Magnitude Response')
Now generate the input signal x by filtering white noise through the AR system. Estimate the PSD of x based on a fourth-order AR model (since we know that the original AR system, a, has order 4).
x = filter(1,a,randn(150,1)); % AR system output pyulear(x,4) % 4th order estimate
![]()
Diagnostics
The first input argument must be a full vector; otherwisepyulear generates the following error message:
Input signal cannot be sparse.If you specify an empty matrix for the second argument,
pyulear generates the following error message:
Model order must be an integer.
See Also
aryule |
Compute an estimate of AR model parameters using the Yule-Walker method. |
lpc |
Linear prediction coefficients. |
pburg |
Power spectrum estimate using the Burg method. |
pcov |
Power spectrum estimate using the covariance method. |
pmcov |
Power spectrum estimate using the modified covariance method. |
pmtm |
Power spectrum estimate using the multitaper method (MTM). |
pmusic |
Power spectrum estimate using MUSIC eigenvector method. |
prony |
Prony's method for time domain IIR filter design. |
pwelch |
Estimate the power spectral density (PSD) of a signal using Welch's method. |
References
[1] Marple, S.L. Digital Spectral Analysis. Englewood Cliffs, NJ: Prentice Hall, 1987. Chapter 7.