简体   繁体   English

如何在 Octave/MATLAB 中计算 IIR 滤波器频率响应

[英]How to compute an IIR Filter frequency response in Octave/MATLAB

I'm trying to compute the frequency response of an IIR filter.我正在尝试计算 IIR 滤波器的频率响应。

The transfer function of the filter is:滤波器的调function为:

The value of a is computed as: a的值计算如下:

f     = 1000;
fsamp = 16000;
a     = 1 / (1 + (2 * pi * f) / fsamp); 

Ok so now I have the transfer function of my IIR filter.好的,现在我有了 IIR 滤波器的传输 function。 How should I now compute the frequency response?我现在应该如何计算频率响应? I thought about using the freqz function, but I need help defining the arguments, how do i define the numerator and denominator polynomials?我考虑过使用freqz function,但我需要帮助定义arguments,如何定义分子和分母多项式?

f=1000; fsamp=16000; a=1/(1+(2*pi*f)/fsamp);
a = [1 -a];
b = [(1-a) 0];
w = logspace(-1,1);

h = freqs(b,a,w);
mag = abs(h);
phase = angle(h);
phasedeg = phase*180/pi;

subplot(2,1,1)
loglog(w,mag)
grid on
xlabel('Frequency (rad/s)')
ylabel('Magnitude')

subplot(2,1,2)
semilogx(w,phasedeg)
grid on
xlabel('Frequency (rad/s)')
ylabel('Phase (degrees)')

This is based on this solution https://www.mathworks.com/help/signal/ref/freqs.html by Mathworks.这是基于 Mathworks 的此解决方案https://www.mathworks.com/help/signal/ref/freqs.html And I get this outcome:我得到了这个结果:

The first two inputs of freqz are respectively the numerator and denominator of the transfer function expressed as polynomials of the variable z −1 : freqz的前两个输入分别是传输 function 的分子和分母,表示为变量z -1的多项式:

a = 0.7; % example value
num = 1-a;
den = [1, -a];
freqz(num, den, 1001)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM