freqz behavior

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

freqz behavior

Tony Richardson-4
I am curious why the frequency vector returned in the second case below extends from 0 to 2 pi instead of from 0 to pi like in the first case.  The help documentation seems to say that the first case is behaving correctly.  Note: The results are correct in both cases.  I am just wondering about the inconsistency. Octave 5.2.0, Windows 10.
Tony

% Poles 0.9 exp(+-j pi/4), Zero at -1
subplot(2, 1, 1)
theta_r = [-1 1]*pi/4;
a = poly(0.9*exp(j*theta_r));
b = poly(-1);
[H1 W1] = freqz(b, a);
plot(W1/pi, abs(H1))

% No poles.  Zeros at angles that are multiples of pi/4 on unit circle except at angle 0
subplot(2, 1, 2)
theta_r = [-3:-1 1:4]*pi/4;
a = 1;
b = poly(exp(j*theta_r));
[H2 W2] = freqz(b, a);
plot(W2/pi, abs(H2))



Reply | Threaded
Open this post in threaded view
|

Re: freqz behavior

Augustin Lefèvre
Hello Tony,

The reason is that you are feeding complex coefficients in the second case, whereas in the first case all coefficients are real.

cf.  "octave/4.2.2/m/signal/freqz.m"




On 18/06/2020 21:57, Tony Richardson wrote:
% Poles 0.9 exp(+-j pi/4), Zero at -1
subplot(2, 1, 1)
theta_r = [-1 1]*pi/4;
a = poly(0.9*exp(j*theta_r));
b = poly(-1);
[H1 W1] = freqz(b, a);
plot(W1/pi, abs(H1))

% No poles.  Zeros at angles that are multiples of pi/4 on unit circle except at angle 0
subplot(2, 1, 2)
theta_r = [-3:-1 1:4]*pi/4;
a = 1;
b = poly(exp(j*theta_r));
[H2 W2] = freqz(b, a);
plot(W2/pi, abs(H2))




Reply | Threaded
Open this post in threaded view
|

Re: freqz behavior

Tony Richardson-4


On Fri, Jun 19, 2020 at 2:28 AM Augustin Lefèvre <[hidden email]> wrote:
Hello Tony,

The reason is that you are feeding complex coefficients in the second case, whereas in the first case all coefficients are real.

cf.  "octave/4.2.2/m/signal/freqz.m"




On 18/06/2020 21:57, Tony Richardson wrote:
% Poles 0.9 exp(+-j pi/4), Zero at -1
subplot(2, 1, 1)
theta_r = [-1 1]*pi/4;
a = poly(0.9*exp(j*theta_r));
b = poly(-1);
[H1 W1] = freqz(b, a);
plot(W1/pi, abs(H1))

% No poles.  Zeros at angles that are multiples of pi/4 on unit circle except at angle 0
subplot(2, 1, 2)
theta_r = [-3:-1 1:4]*pi/4;
a = 1;
b = poly(exp(j*theta_r));
[H2 W2] = freqz(b, a);
plot(W2/pi, abs(H2))
Augustin,

Thank you.  I'll note that the coefficients are theoretically real, but numerically complex (very small imag part).  I should compute the coefficients from the pole/zero conjugate pairs instead of from the individual pole/zero locations to ensure real coefficients, but I was trying to get the result using a quick-and-dirty method (never a good idea).  

Your code snippet points out that I can get consistent results by always using the "region" argument with either "whole" or "half".  Only, the "whole" option is mentioned in the help documentation, it would be more "help"ful to also mention the "half" option and/or mention that "whole" is the default if the coefficients are complex.

Tony