Reputation: 471
I want to do fft of an accelerometer data from android phone.I have chosen jtransform as fft library.Now I need some simple code to understand jtranform to write code to find fft from accelerometer data. Thanks in advance
Upvotes: 4
Views: 1720
Reputation: 4821
Since you have the real data, you should pass these values to realForward
function as stated here. When you pass the value array to this function it returns the results by overwriting this array with the FFT coefficients.
array = new double[arraySize];
...
DoubleFFT_1D dfft = new DoubleFFT_1D(arraySize);
dfft.realForward(array);
You should also consider the fact that output contains both real and imaginary parts:
if arraySize
is even then
array[2*k] = Re[k], 0 <= k < arraySize/2
array[2*k+1] = Im[k], 0 < k < arraySize/2
array[1] = Re[arraySize/2]
if arraySize
is odd then
array[2*k] = Re[k], 0 <= k < (arraySize+1)/2
array[2*k+1] = Im[k], 0 < k < (arraySize-1)/2
array[1] = Im[(arraySize-1)/2]
Upvotes: 1