We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
我们必须对我最近从事的一个项目的一些数据应用巴特沃斯滤波器。 (由于测量仪器变热,压力测量值会随着时间的推移而漂移。)实际上,它比包含库还要简单。 您实际上只需要包含一个函数并将其添加到您需要使用它的任何 C 文件中。
这是我们用来生成过滤器的站点:
http://www-users.cs.york.ac.uk/~fisher/mkfilter/
如果指定参数,它将为您生成该函数。 这是我们在应用程序中使用的函数示例,基于上述网站生成的代码。 (我们 typedef DOUBLE 因为它是在 PC 上开发的,但针对的是嵌入式平台——我们需要确保大小不会改变。)
我喜欢阅读这个网站,很高兴终于能做出一些贡献!
We had to apply a Butterworth Filter to some data on a project that I worked on recently. (Pressure measurements that drift over time because the measuring instrument heats up.) It's actually even simpler than including a library. You really just need to include a single function and add it to whatever C file you need to use it in.
This is the site that we used to generate our filter:
http://www-users.cs.york.ac.uk/~fisher/mkfilter/
If you specify the parameters, it will generate the function for you. Here is an example of the function we used in our application, based on the code generated by the above website. (We typedef DOUBLE because it's being developed on a PC, but targeted for an embedded platform -- we need to make sure that the size doesn't change.)
I love reading this site, glad to finally have something to contribute!
几乎可以肯定,使用经过良好测试的外部库(假设您可以找到一个……尝试过 Google 吗?)比自己编写一个不平凡的过滤器更简单、更安全。
但是,由于您没有透露有关您的应用程序、数据格式等的任何内容,因此我们无法告诉您更多信息。
我对您的 IDE (CodeBlocks) 工作原理一无所知,但导入通常采用三种形式之一,具体取决于您如何使用该库(详细信息如下):
......无论如何,您有时都会
在某些源文件中执行操作,以使外部功能对您的代码可见。
您可能想首先找到一个候选库,看看它以什么形式提供,然后阅读有关您的 IDE 的更多信息以了解下一步的发展方向。
另一个可能与您的需求相关的问题:模拟电路仿真库?。
我已经很久没有使用 matlab 了,但如果这是您的基本编程经验,您应该意识到 matlab 为您提供的很多功能是普通 c 语言所没有的。 您几乎肯定希望使用某种框架或其他框架来为您提供一些支持。
It is almost certainly simpler and safer to use a well tested external library (assuming you can find one....tried Google yet?) than to code a non-trivial filter yourself.
But, since you haven't said anything about you application, the format of you data, etc, there is little more that we can tell you.
I don't know anything about how your IDE (CodeBlocks) works, but importing usual takes one of three forms depending on how the library is made available to you (details to follow):
In any case you will at some point be doing
in some of your source files to make the external functionality visible to your code.
Probably you want to find a candidate library first, to see what form it is provided in, then read more about your IDE to see where you go from there.
Another SO question that might be relevant to your needs: Analog circuit simulation library?.
It's been a long time since I used matlab, but if that is your base programming experience, you should be aware that there are a lot of facility that matlab provided to you that are not in plain vanilla c. You almost certainly want to use some framework or another to give you some of that support back.
如果您使用 Matlab,从 C 代码链接到 Matlab 是否是禁忌? 这个 是一个起点。 实际上,您可以通过从 C 调用来要求 Matlab 引擎执行您在 Matlab 接口中可以执行的任何操作。
巴特沃斯滤波器是递归的,因此应将其实现为 IIR 滤波器。 一旦您从 Matlab 测试中获得了稳定的滤波器系数,您就可以将它们简单地输入通用 IIR 算法(非常简单)。 您可以使用大型 FIR 滤波器和卷积来近似滤波器响应,可以将其移至频域以解决相位问题,但如果这样做,则不是真正的巴特沃斯。
我建议从头开始构建一个算法作为学习练习,但如果您尽快需要它,可能有很多库可以帮助您。 此出现在搜索中。
If you're using Matlab, is it taboo to link to Matlab from your C code? This is a starting point. You can actually ask the Matlab engine to do anything you can do from within the Matlab interface by calling it from C.
A Butterworth filter is recursive, so it should be implemented as an IIR filter. Once you have stable filter coefficients from your Matlab testing you can simply feed them to a generic IIR algorithm (pretty simple). You can approximate the filter response with a large FIR filter and convolution, which can be moved into frequency domain to solve phase problems, but it's not truly Butterworth if you do that.
I'd recommend building an algorithm from scratch as a learning exercise, but if you need it ASAP there's probably any number of libraries out there to help you. This came up in search.
Steve Harris 的 SWH LADSPA 插件包中有 Butterworth 过滤器,位于
http://plugin.org.uk
编辑:现在除外我记得 C 代码由于各种原因嵌入到 RDF 中并自动生成。
There's butterworth filters in Steve Harris's SWH LADSPA plugins package at
http://plugin.org.uk
Edit: Except now I recall the C code is embedded within RDF for various reasons and generated automatically.
这是最好的过滤器生成器
http://www-users.cs.york.ac .uk/~fisher/mkfilter/trad.html
不幸的是,它在 C 代码生成时开始失败。 但是,它以接近 C 代码的形式发出足够的信息,以便您可以重现类似于 Mike 建议的内容。 您不需要任何额外的库。 当您想要更新系数(可变截止频率)时,库可能很有用。 我不知道在你的程序中计算这些系数的算法。
This one is the best filter generator
http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html
Unfortunately, it started to fail at the C code generation. But, it emits has enough information in the form close to the C code so that you can reproduce the program similar to what Mike proposes. You do not need any extra libraries for that. Libraries may be useful when you want to update your coefficients (variable cutoff frequencies). I do not know algorithms to compute those coefficients in your program.