# Getting frequencies out of a FFT

I use this FFT and wrote a short program to test it.

package test_FFT;
import org.apache.commons.math3.transform.FastFourierTransformer;
import org.apache.commons.math3.transform.DftNormalization;
import org.apache.commons.math3.transform.TransformType;

public class FFT2 {

public static void main(String[] args) {
double[][] array=new double;
//An array of complex numbers with real part array[*]
//and complex part array[*]
//The output of the transformation will be saved in the input array
array=5.0;
array=2.0;
array=3.0;
array=4.0;
array=5.0;
array=6.0;
array=7.0;
array=9.0;
FastFourierTransformer.transformInPlace(array,DftNormalization.STANDARD,TransformType.FORWARD);

for(int i=0;i<8;i++){
System.out.println("real "+array[i]);
System.out.println("complex "+array[i]);
}

}

}


In the output array I get amplitudes of sin and cos functions. The information about the frequencies should depend on the position within the output array. After some research on this page, I still don't understand how to calculate frequencies out of array positions.

I learned that there are many flavours of how to perform a FFT. Has anyone of you detailed knowledge on how calculate frequencies out of output of the FFT I use? A code sample computing frequencies for the output of the example below would be greatly appreciated. Thank you

• I guess this should answer your question. Apr 1 '16 at 16:28

the magnitude is quite easy.. it is the $abs(array (real + imag)$. the phase $\phi = \arctan \frac{imag}{real}$
in this way it is common to show the half the frequency array because of it's symmetry. if you plot $array$ to $array[N/2]$ you shoult get your frequecy array from $\frac{1}{N}$ to $\frac{F_s}{2}$
• should this be from $0Hz$ to $\frac{Fs}{2}$ ? Apr 1 '16 at 19:35