yulewalk
Designing a recursive digital filter.
| Library |
|
Arguments
Input arguments
# n — filter order
+
a positive integer scalar
Details
The filter order, specified as a positive integer scalar.
| Типы данных |
|
# f — frequency values
+
vector
Details
Frequency values set as a vector with elements ranging from 0 before 1, where 1 corresponds to the Nyquist frequency, or half the sampling frequency. The first element f must be equal to 0, and the last one — 1. All intermediate elements must be arranged in ascending order. Vector f It may have repeated frequency values corresponding to the steps of the frequency response.
| Типы данных |
|
Output arguments
# b, a are the coefficients of the filter
+
string vectors
Details
The filter coefficients returned as row vectors. The coefficients of the output filter are ordered in descending order of degrees :
Examples
Designing a low—pass filter using the Yule-Walker method
Details
Let’s design a low-pass filter 8-th order with a normalized cutoff frequency 0.6. Let’s construct its frequency response and superimpose on it the characteristic of the corresponding ideal filter.
import EngeeDSP.Functions: yulewalk, freqz
f1 = [0, 0.6, 0.6, 1]
m1 = [1, 1, 0, 0]
b1,a1 = yulewalk(8,f1,m1)
h1,w1 = freqz(b1,a1,128)
p = plot(w1/π, mag2db.(abs.(h1)),
xlabel = "ω/π",
ylabel = "Magnitude (dB)",
grid = true,
legend = false,
linecolor = :blue)
vline!(f1[2:3], linestyle = :dash, linecolor = :black)

Increase the attenuation in the suppression band by specifying a wider transition band.
f2 = [0, 0.55, 0.6, 0.65, 1]
m2 = [1, 1, 0.5, 0, 0]
b2,a2 = yulewalk(8,f2,m2);
h2,w2 = freqz(b2,a2,128)
plot!(w2/π, mag2db.(abs.(h2)),
linecolor = :red)

Recommendations
When setting the frequency response, avoid excessively abrupt transitions from the bandwidth to the barrier band. You may need to experiment with the slope of the transition region to obtain an optimal filter design.
Algorithms
Function yulewalk constructs recursive digital IIR filters using the least squares method to approximate a given frequency response. The approximation is performed in the time domain.
-
To calculate the coefficients of the denominator, the function
yulewalkIt uses modified Yule—Walker equations, the correlation coefficients of which are calculated using the inverse Fourier transform of a given frequency response. -
To calculate the numerator, the function
yulewalkperforms the following steps:-
Calculates the numerator polynomial corresponding to the additive decomposition of the power-frequency characteristic.
-
Calculates the total frequency response corresponding to the polynomials of the numerator and denominator.
-
Uses the spectral factorization method to obtain the impulse response of the filter.
-
Obtains the numerator polynomial by least squares approximation of this impulse response.
-