简体   繁体   English

Matlab IIR滤波器传递函数

[英]Matlab IIR Filter transfer function

I am using MATLAB to design a filter and obtain the transfer function coefficients a and b in order to then code the filter in C. 我正在使用MATLAB设计滤波器并获得传递函数系数ab ,然后用C编码滤波器。

However I have noted that the function sos2tf is creating different values than expected. 但是我注意到函数sos2tf正在创建不同于预期的值。 In fact when using fvtool to view the filter using the b and a coefficients the filter looks different than that of I plot it using the sos matrix or the actual filter f . 事实上,当使用fvtool以查看使用的过滤器ba系数滤波器看起来比不同的我使用绘制它sos矩阵或实际滤波器f

If you try the below code you can understand better what I am saying. 如果你尝试下面的代码,你可以更好地理解我在说什么。 Is this a function problem coming from MATLAB? 这是一个来自MATLAB的函数问题吗? Can I use substitutes to sos2tf which gives me the required filter coefficients? 我可以使用sos2tf替代品来sos2tf所需的滤波器系数吗? Or can I retrieve them directly without first using sos ? 或者我可以直接检索它们而无需先使用sos吗?

Note that I have already tried using designfilt and then using the tf function and the resulting coefficients came to be exactly equal to those obtained with the code below. 请注意,我已经尝试使用designfilt然后使用tf函数,结果系数与下面的代码获得的系数完全相同。 Thanks for your help 谢谢你的帮助

H = fdesign.lowpass('Fp,Fst,Ap,Ast',60,75,1,60,10000);
f = design(H,'butter','MatchExactly','passband');  % Design an FIR BW filt
info(f)                   % View information about filter
fvtool(f);
[b,a] =  sos2tf(f.sosMatrix);
fvtool(b,a);

I don't know exactly what the problem is, as it isn't working for me either, but I'm going to give you a workaround to get the filter coefficients. 我不知道究竟是什么问题,因为它对我来说也不起作用,但我会给你一个解决方法来获得滤波器系数。 In Matlab Command Window type fdatool,a filter design app window will pop up, design your filter there by properly choosing the desired parameters. 在Matlab命令窗口类型fdatool中,将弹出一个过滤器设计应用程序窗口,通过正确选择所需参数来设计过滤器。 Once you're done, in that fdatool window go to File->Export->Export As-> Coefficients. 完成后,在该fdatool窗口中转到File-> Export-> Export As-> Coefficients。 From that very same tool you can select File-> generate matlab code-> Filter design function (or any of the 3 options). 从同一个工具中,您可以选择File-> generate matlab code-> Filter design function(或3个选项中的任何一个)。 And that way you eliminate possible bugs there might be in the code you posted in your question. 这样你就可以消除你在问题中发布的代码中可能存在的错误。 That's how I do it and it has always worked well 我就是这样做的,而且一直运作良好

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

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