Am I using yulewalk() correctly?

5 views (last 30 days)
Christoph F.
Christoph F. on 20 Sep 2016
Commented: Christoph F. on 29 Sep 2016
I am trying to figure out if I am using the yulewalk function (signal processing toolbox) correctly.
In a basic example, I try to find the filter coefficients of a filter previously generated with MatLAB. I would expect yulewalk to generate a filter that exactly matches the original filter.
% Generate second-order Butterworth filter
[Bx, Ax]=butter(2, 0.13)
% Calculate frequency and magnitude vectors
[H, F]=freqz(Bx, Ax, 0:0.01:1, 2);
% Use yulewalk to generate a filter that should match Bx and Ax
[B, A] = yulewalk(2, F, abs(H))
However, [B, A] is completely different from [Bx, Ax].
Other, similar functions (invfreqz, stmcb) generate a filter that exacly matches the original, but they either work with complex amplitudes (invfreqz) or in the time domain (stmcb).
Is this a limitation of the Yule-Walker algorithm, or am I using the yulewalk function incorrectly?

Answers (1)

Michael Abboud
Michael Abboud on 27 Sep 2016
The Yule-walker filter design does not use phase information for the design of the filter, so filters with different coefficients could give you the same magnitude response, but different phase and amplitude.
Also, order 2 is a rather low for such a system, and will likely lead to a rough approximation of the coefficients. However if you increase the order, e.g [B, A] = yulewalk(10, F, abs(H)); then you will obtain a response that has a very similar magnitude to the original system.
If you have any further questions, feel free to contact MathWorks Technical Support and somebody can work with you more closely about your specific use case.
  1 Comment
Christoph F.
Christoph F. on 29 Sep 2016
Thank you for your answer. While yulewalk() does indeed produce a closer approximation of the original system when the order is increased, the original system is only a second order system and could be matched exactly by a second order system with the same coefficients. My example did not introduce any noise or other uncertainties that would disturb the approximation.
yulewalk() appears not to find the exact solution in the simple example, even when it is given a large number of data points. The other system identification/filter design functions (invfreqz, stmcb) will find the exact match, even when given only the strictly necessary number of data points.
I am asking about yulewalk () since I often find myself wanting to design short (1st to 4th order) IIR filters that have a given magnitude response at certain frequencies and where the phase response is not relevant. From the description of the function, it sounds like yulewalk() is the tool for this type of task, but it does not produce an exact solution even in cases where an exact solution is possible, e.g.
[B, A]=yulewalk(2, [0 0.5 1], [1 0.5 0]);
or even the trivial case
[B, A]=yulewalk(1, [0 1], [1 0]); % one exact solution: B = [0.5 0.5], A=[1 0]

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!