简体   繁体   English

MATLAB:IIR 滤波器系数

[英]MATLAB: IIR Filter coefficients

I am fairly new in signal processing, and one of my projects is to implement a C++ filter class.我在信号处理方面相当新,我的一个项目是实现 C++ 过滤器类。 I need the higher order coefficients of typical filters such as Chebyshev types I and II, Butterworth, Elliptic, and unfortunately, most of the coefficient tables in the net only lists up to 10th order max.我需要典型滤波器的高阶系数,例如 Chebyshev I 型和 II 型、Butterworth、Elliptic,不幸的是,网络中的大多数系数表只列出了最多 10 阶的最大值。 I decided to use MATLAB to generate these filters and get their higher order coefficients, however one thing that I'm confused about is that they only give out 1 set of coefficients, which I assume to be analogous to saying (ao,a1,a2.....an).我决定使用 MATLAB 来生成这些滤波器并获得它们的高阶系数,但是我感到困惑的一件事是它们只给出一组系数,我认为这类似于说 (ao,a1,a2 .....一个)。

I learned that IIR filters have 2 sets of coefficients, usually expressed as a0,a1...an and b0,b1,...,bn.我了解到 IIR 滤波器有 2 组系数,通常表示为 a0,a1...an 和 b0,b1,...,bn。 Here is my MATLAB code to generate these coefs and export them to an excel file:这是我生成这些系数并将它们导出到 excel 文件的 MATLAB 代码:

 %Chebyshev Filter Coefficients

 filename = 'cheby2coefs.xlsx';
 for Order = 1:64 
 fprintf('This is');
 disp(Order);
 fprintf('coefficients');
 [i,j] = cheby2(Order, 20, 300/500);
 disp([i,j]);
 fprintf('\n');

  xlswrite(filename,[i,j]',Order);
end

So far there has been little sources on the net on how to come up with these coefficients with MATLAB, so I'm having a hard time.到目前为止,网上关于如何用 MATLAB 得出这些系数的资料很少,所以我很难过。 My question is that, how exactly does one produce the IIR coefficients for these filters (Assuming they're IIR)?我的问题是,究竟如何为这些滤波器产生 IIR 系数(假设它们是 IIR)?

It looks like you're on the right track.看起来你走在正确的轨道上。 Your call to cheby2 is missing the Wst parameter (the stopband frequency).您对cheby2调用缺少Wst参数(阻带频率)。 You should read MATLAB's official documentation for this command and verify your call.您应该阅读此命令的MATLAB 官方文档并验证您的调用。

Also, don't name the output variables i and j , it's bad practice.另外,不要命名输出变量ij ,这是不好的做法。 i and j are reserved names for the sqrt(-1) imaginary number. ijsqrt(-1)虚数的保留名称。 Name the output variables b and a at least.至少将输出变量命名为ba

Once you're done with Chebyshev, use butter and ellip for the Butterworth and elliptic filters, respectively.完成 Chebyshev 后,分别对 Butterworth 和椭圆滤波器使用butterellip

This seems to be covered in the MATLAB documentation :这似乎包含在MATLAB 文档中

[b,a] = cheby2(n,R,Wst) designs an order n lowpass digital Chebyshev Type II filter with normalized stopband edge frequency Wst and stopband ripple R dB down from the peak passband value. [b,a] = cheby2(n,R,Wst) 设计了一个 n 阶低通数字 Chebyshev II 型滤波器,其具有归一化的阻带边缘频率 Wst 和阻带纹波 R dB 低于峰值通带值。 It returns the filter coefficients in the length n+1 row vectors b and a, with coefficients in descending powers of z.它返回长度为 n+1 行向量 b 和 a 的滤波器系数,系数为 z 的降幂。

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

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