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[2][8];
//An array of complex numbers with real part array[0][*]
//and complex part array[1][*]
//The output of the transformation will be saved in the input array
array[0][0]=5.0;
array[0][1]=2.0;
array[0][2]=3.0;
array[0][3]=4.0;
array[0][4]=5.0;
array[0][5]=6.0;
array[0][6]=7.0;
array[0][7]=9.0;
FastFourierTransformer.transformInPlace(array,DftNormalization.STANDARD,TransformType.FORWARD);

for(int i=0;i<8;i++){
System.out.println("real "+array[0][i]);
System.out.println("complex "+array[1][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. – Matt L. 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[0]$ 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}$ ? – gerrgheiser Apr 1 '16 at 19:35