简体   繁体   中英

Can't get Exocortex FFT to work

I'm writing an application that will analyze data from an accelerometer. One of the most important algorithms for this is obviously the FFT, and after much looking I found that Exocortexs library is one of the best for this.

Anyway, when I try to implement it I get this exception:

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

Additional information: must be a power of 2

Here's the code:

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;

(This is really just a version of this example: Fast Fourier Transform in C# ).

The problem might be as simple as the imaginary part of the acceleration since I assume this kind of data is only real but the answer, the FFT that is, is imaginary.

Thanks in advance!

I'm gonna go out on a limb here and suggest that your vectorLength variable is not a a power of 2 .

Try cropping your data such that its new length L = N^2, where integer N > 1. Does that get ride of the exception?

Are you expecting your signal to be periodic in nature? Is it attached to some mechanism rotating/shaking at fairly steady frequency? If not, what would you hope to get out of using an FFT?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM