0

我正在编写一个应用程序来分析来自加速度计的数据。最重要的算法之一显然是 FFT,经过仔细研究,我发现 Exocortexs 库是最好的算法之一。

无论如何,当我尝试实现它时,我得到了这个异常:

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in Exocortex.DSP.v1.dll

Additional information: must be a power of 2

这是代码:

class FFT
    {
        public Exocortex.DSP.ComplexF[] FourierTransform(List<double> vector)
        {
            //Dictionary<string, List<double>>

            int vectorLength = vector.Count;
            Exocortex.DSP.ComplexF[] complexData = new Exocortex.DSP.ComplexF[vectorLength];

            for (int i = 0; i < vectorLength; ++i)
            {
                complexData[i].Re = Convert.ToSingle(vector[i]); // Add your real part here
            //    complexData[i].Im = 2; // Add your imaginary part here
            }

            Exocortex.DSP.Fourier.FFT(complexData, Exocortex.DSP.FourierDirection.Forward);

            return complexData;

(这实际上只是此示例的一个版本:Fast Fourier Transform in C#)。

问题可能就像加速度的虚部一样简单,因为我假设这种数据只是真实的,但答案,即 FFT,是虚构的。

提前致谢!

4

1 回答 1

2

我要在这里冒险并建议您的vectorLength变量不是a power of 2.

尝试裁剪您的数据,使其具有新的长度L = N^2, where integer N > 1. 是否可以解决异常?

您是否希望您的信号本质上是周期性的?它是否连接到某些以相当稳定的频率旋转/摇晃的机构?如果不是,您希望从使用 FFT 中得到什么?

于 2013-11-14T20:13:46.723 回答