MATLAB过滤代码 [英] MATLAB filter code
问题描述
要生成我选择的滤波器设计代码:文件>生成MATLAB代码> MAT文件。
这是正确的方法吗?
生成代码后,如何才能正弦波使用它?
感谢您提供任何帮助。 $ b
如果有效,这是没有错的。您想要将代码存储在.m文件中。您可以运行该功能,然后创建您的过滤器对象。你也可以通过编辑函数使其更加动态(如添加输入参数以使其适用于其他频率或采样频率)。要确认它的工作原理,您可以使用 freqz
来选择数字频率响应。要过滤一个信号,你可以使用 filter 。
$ $ $ $ $ $ $ $ $ yFilt =过滤器(Hd,y0);
其中 y0
是原始信号 yFilt
过滤信号, Hd
过滤器对象。你也可以尝试白噪声滤波器。 AWGN的频率响应应该与滤波器的频率响应一致。
I designed an FIR filter (highpass) in the FDAtool. Now I have a sine wave created using MATLAB code which I need to pass from the filter to monitor its performance. To generate the filter design code I selected: File > generate MATLAB code > MAT-file. Is this the correct way to do it? After the code is generated, how can I use it with the sine wave?
Thanks in advance for any kind of help.
If it works, it is not wrong. You want to store the code in a .m file though. You can run the function then to create your filter object. You can also make it more dynamic if you want by editing the function (like add input arguments to let it work for other frequencies or sampling frequencies as well). To confirm it works as it should you can use freqz
to se the digital frequency response. To filter a signal then, you can use filter
.
yFilt = filter(Hd, y0);
where y0
is the original signal yFilt
the filtered signal and Hd
the filter object. You can try the filter with white noise as well. The frequency response for AWGN should be the same as the filter's frequency response.
这篇关于MATLAB过滤代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!