帮助使用 EXCEL 快速傅里叶变换

发布于 2024-10-08 19:39:54 字数 299 浏览 0 评论 0原文

我正在尝试使用 Excel(2007)内置的 FFT 功能,但是,它要求我有 2^n 个数据点 - 但我没有。

我尝试了两件事,都给出了不同的结果:

  1. 将数据值填充为零,以便 N(数据点的数量)达到最接近的 2 的幂
  2. 使用分而治之的方法,即如果我有 112 个数据点,那么我对 64 进行 FFT,然后对 32 进行 FFT,然后对 16 进行 FFT (112=64+32+16)

哪种方法更好?我很擅长编写 VBA 宏,但我正在寻找一种不需要 N 是 2 的幂的约束的算法。有人可以帮忙吗?

I am trying to use Excel's (2007) built in FFT feature, however, it requires that I have 2^n data points - which I do not have.

I have tried two things, both give different results:

  1. Pad the data values by zeros so that N (the number of data points) reach the closest power of 2
  2. Use a divide-and-conquer approach i.e. if I have 112 data points, then I do a FFT for 64, then 32, then 16 (112=64+32+16)

Which is the better approach? I am comfortable writing VBA macros but I am looking for an algorithm which does not require the constraint of N being power of 2. Can anyone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

゛时过境迁 2024-10-15 19:39:54

将数据分割成较小的位将导致错误的输出,尤其是对于较少数量的数据点。

用零填充是一个更好的主意,也是 FFT 的一般方法。如果您对执行 FFT 的替代方法感兴趣,octave 会为您完成,并且大多数 Matlab 文档都适用,因此您应该不会遇到任何问题。

Splitting your data into smaller bits will result in erroneous output, especially for smaller numbers of data points.

Padding with zeroes is a much better idea, and the general approach for FFTs. If you are interested in an alternative way of doing the FFT, octave will do it for you, and most of the Matlab documentation applies so you should have no trouble with it.

愛放△進行李 2024-10-15 19:39:54

用零填充是正确的方向,但请记住,如果您进行变换是为了估计频率内容,则需要一个 窗口函数,并且应该应用于短块(即,如果您有 2000 个点,则应用 2000 点 Hann 窗口,然后填充到 2048 并计算变换)。

如果您正在开发插件,您可能会考虑使用众多 FFT 库之一。我是 Marc Borgerding 的 KISS FFT 的忠实粉丝。它为许多块大小提供快速转换,基本上是任何可以分解为数字 2、3、4 和/或 5 的块大小。但它不处理素数大小的块。它是用非常简单的 C 语言编写的,因此应该很容易移植到 C#。或者,这个问题建议了一些可以在 .网。

Padding with zeros is the right direction, but keep in mind that if you're doing the transform in order to estimate frequency content, you will need a window function, and that should be applied to the short block (i.e., if you have 2000 points, apply a 2000 point Hann window, then pad to 2048 and calculate the transform).

If you're developing an add-in, you might consider using one of the many FFT libraries out there. I'm a big fan of KISS FFT by Marc Borgerding. It offers fast transforms for many blocksizes, essentially any blocksize that can be factored into the numbers 2,3,4, and/or 5. It doesn't handle prime number sized blocks though. It's written in very plain C, so should be easy to port to C#. Or, this SO question suggests some libraries that can be used in .NET.

赴月观长安 2024-10-15 19:39:54

用零填充

2^n 是 FFT 算法的要求。

也许是对已知时间序列的测试(例如,单个频率的简单正弦或余弦)。当你对其进行 FFT 时,你应该得到一个单一频率(狄拉克δ函数)。其他任何内容都是错误。使用 2 的整数幂进行计算,并用零填充等。

pad out with zeros

2^n is a requirement of the FFT algorithm.

Maybe a test of a known time series (e.g., simple sine or cosine of a single frequency). When you FFT that, you should get a single frequency (Dirac delta function). Anything else is an error. Do it with an integer power of two, padded with zeroes, etc.

洋洋洒洒 2024-10-15 19:39:54

您可以用零填充,也可以使用支持任意大小的 FFT 库。此类库之一是 https://github.com/altomani/XL-FFT

它将 FFT 实现为带有 LAMBDA 函数的纯公式(即没有任何 VBA 代码)。
对于二长度的幂,它使用递归基数 2 Cooley-Tukey 算法
对于其他长度,
Bluestein 算法 的版本可将计算量减少到 2 的幂案件。

You can pad with zeros, or you can use an FFT library that supports arbitrary sizes. One such library is https://github.com/altomani/XL-FFT.

It implements the FFT as a pure formula with LAMBDA functions (i.e. without any VBA code).
For power of two length it uses a recursive radix-2 Cooley-Tukey algorithm
and for other length a version of Bluestein's algorithm that reduces the calculation to a power of two case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文