freqz() not behaving as expected?

I have noticed something abnormal about freqz() not as expected. For example, I want to plot a response of a delay z^-n, so I put in this code:
b = 1;
a = [1 0 0 0];
[h,w] = freqz(b, a, 1000);
plot(w, angle(h));
I expect to get a linear phase slope waveform of sawtooth. Instead I got a flat line at 0.
Also, I try to plot the phase response of an integrator:
b = 1;
a = [1 -1];
[h,w] = freqz(b,a,1000);
plot(w, angle(h));
grid;
I expect to get a phase line sloping down starting from -pi/2 to -pi. Instead it plots a line slopping up. This is strange.

回答 (1 件)

Paul
Paul 2023 年 6 月 6 日
編集済み: Paul 2023 年 6 月 6 日

1 投票

The b and a inputs to freqz are the coefficients in ascending powers of z^-1. So this case
b = 1;
a = [1 0 0 0];
really means:
H(z) = 1/(1 + 0*z^-1 + 0z^-2 + 0*z^-3) = 1,
which is exactly what freqz produces
figure
freqz(b, a, 1000);
If you want H(z) = z^-3, then we'd have
b = [0 0 0 1];
a = 1;
figure
freqz(b,a,1000)

1 件のコメント

Xiangguang
Xiangguang 2023 年 6 月 6 日
編集済み: Xiangguang 2023 年 6 月 6 日
Thanks a lot. You saved me headache.

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2023 年 6 月 6 日

編集済み:

2023 年 6 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by