非log-base2数字的Matlab FFT(快速傅立叶变换)功能 [英] Matlab FFT (Fast Fourier Transform) function of non log-base2 numbers

查看:111
本文介绍了非log-base2数字的Matlab FFT(快速傅立叶变换)功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在开发的应用程序可以实现 Apple的Accelerate Framework FFT函数,我正在尝试使其模仿

I have an app that I am developing that utalizes Apple's Accelerate Framework FFT function and I am trying to make it mimic the functionality of Matlab's FFT function. I have my current code set up to output exactly the same way as I am doing so in matlab. The only time that it doesn't output identically is when the number of elements in the data array are != a logarithm of base 2 (technically necessary for an FFT). I was wondering if anyone knew how the Matlab Function handled this case. If I do it using the apple code, it produces different results.

注意:我不是简单地调用fft(x).我也对FFT进行移位并取绝对值并将其平方.我还将它们反映在苹果代码中,因为它们不受FFT的直接影响.他们被称为事实.

Note: I am not simply calling fft(x). I also FFT shift and take the absolute value and square it. I also mirror these in the apple code because they aren't directly affected by the FFT. They are called after the fact.

示例1-16个元素(以2为底的对数):类似输出

Example 1 - 16 Elements (Log base 2): Similar Output

Matlab电话:

x = 1:16;
Fxx = abs(fftshift(fft(x))).^2;

Fxx =

  Columns 1 through 7

64    66.5322    74.9807    92.5736    128    207.3490    437.0193

 Columns 8 through 14

1681.5451    18496    1682.5451    437.0193    207.3490    128    92.5736

  Columns 15 through 16

74.9807    66.5322

* 由于长度原因省略了苹果代码

Apple输出:

Fxx[0] = 64.000000
Fxx[1] = 66.532232
Fxx[2] = 74.980664
Fxx[3] = 92.573612
Fxx[4] = 128.000000
Fxx[5] = 207.349044
Fxx[6] = 437.019336
Fxx[7] = 1681.545112
Fxx[8] = 18496.000000
Fxx[9] = 1681.545112
Fxx[10] = 437.019336
Fxx[11] = 207.349044
Fxx[12] = 128.000000
Fxx[13] = 92.573612
Fxx[14] = 74.980664
Fxx[15] = 66.532232

示例2-10个元素(非对数2):不同的输出

Example 2 - 10 Elements (NOT Log base 2): Different Output

Matlab电话:

x = 1:10;
Fxx = abs(fftshift(fft(x))).^2;

Fxx = 

Columns 1 through 7

25    27.6393    38.1966    72.3607    261.8034    3025    261.8034

Columns 8 through 10

72.3607    38.1966    27.6393

* 由于长度原因省略了苹果代码

Apple输出:

Fxx[0] = 16.000000
Fxx[1] = 45.250000
Fxx[2] = 18.745166
Fxx[3] = 32.000000
Fxx[4] = 109.254834
Fxx[5] = 1296.000000
Fxx[6] = 109.254834
Fxx[7] = 32.000000
Fxx[8] = 18.745166
Fxx[9] = 45.250000

如您所见,在第一个示例中,与第二个示例相比,它们显然产生了相同的输出.我已经对正负输入进行了测试,唯一不同的是它们不是基于日志的2.有人知道Matlab如何处理此问题吗?也许它用0填充数组,直到它的对数为2,然后对某些点取平均值?我已经做了很多搜索,在这种特殊情况下,无法弄清楚他们做了些什么来获取输出.

As you can see, they clearly produce the same output in the first example vs the second. I have tested with both positive and negative inputs and the only time they are different is when they are NOT log base 2. Does anyone know how Matlab handles this problem? Perhaps it fills the array with 0's until its a log base 2 number and then do the average of certain points? I have done lots of searching and cannot figure out what they do to obtain their output in this special case.

推荐答案

来自官方MATLAB文档:

FFT函数(fft,fft2,fftn,ifft,ifft2,ifftn)基于名为 FFTW .

要在N为复合值(即N = N 1 N 2 )时计算N点DFT,FFTW库使用<一种href ="http://en.wikipedia.org/wiki/Cooley%E2%80%93Tukey_FFT_algorithm" rel ="nofollow"> Cooley-Tukey算法,该算法首先计算N 1 大小为N 2 的变换,然后计算大小为N 1 的N 2 个变换.

To compute an N-point DFT when N is composite (that is, when N = N1N2), the FFTW library decomposes the problem using the Cooley-Tukey algorithm, which first computes N1 transforms of size N2, and then computes N2 transforms of size N1.

当N是质数时,FFTW库首先使用

When N is a prime number, the FFTW library first decomposes an N-point problem into three (N – 1)-point problems using Rader's algorithm. It then uses the Cooley-Tukey decomposition described above to compute the (N – 1)-point DFTs.

我不确定Apple的Accelerate Framework如何计算此类FFT,但我在这里偏爱MATLAB来产生正确的结果.

I'm not sure how Apple's Accelerate Framework computes such FFTs, but I'm favouring MATLAB here to produce correct results.

这篇关于非log-base2数字的Matlab FFT(快速傅立叶变换)功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆