0

I am sampling at $30 Hz$.

I have a sample of $N=150$.

Here is an example of how my sample looks like, which starts at 54 and ends on 203 on the X Axisenter image description here

I am interested in observing frequencies between 15 and 20 per minute. ( Cycles per minute ) Hence, I would derive the cycles per second ( Hz ) like this.

$15*0.0166666666667=0.25 \ Hz$

$20*0.0166666666667=0.33 \ Hz$

When I take the FFT, my data looks as follows. ( X axis are the bins to N / 2, not frequency )

enter image description here

To derive the frequency for each bin, I am using this stack answer to construct this logic:

Frequency = ( bin * sampleRate ) / dft.Points

So I might have some output as follows:

Frequency = 0 * 30/300
Frequency = 1 * 30/300
Frequency = 2 * 30/300
Frequency = 3 * 30/300

If I re-plot the same data, where the X axis now represents frequency, this is what I get :

enter image description here

Here is where my question kicks in: ( Note, if something above is wrong in my logic, please point it out, as it could be the reason why I am getting weird results )

I now want to take the IFFT of the dataset, given that the frequency of the bin is less than . Here is some java code to help illustrate how I am doing this with JTransforms:

final double[] ifft = new double[fft.length];
for (int idx = 0; idx < fft.length; idx++) {
    final double fftPoint = fft[idx];
    final Double sampleCount = Double.valueOf(idx * 30);
    final Double binToFrequency = Double.valueOf(sampleCount / fft.length);
    ifft[idx] = binToFrequency <= 0.33333334 ? fftPoint : 0;
}

analyzer.realInverseFull(ifft, false);

Variable fft above is the DFT/FFT array data points. Since I have 150 samples. fft.length should equate to 300. I am then checking the frequency of the bin, and if it is less than 0.33333334 I am using it, otherwise, it is getting zeroed out.

When I plot my graph, the odd part is that I get two waves:enter image description here

If I zoom in on the top one, here is what I see:enter image description here

I also notice that the numbers on the x axis are increments of 2. For example, the wave where the amplitude is around 400K on the Y axis starts at 1, and has points at 3,5,7,9, etc. The lower one starts at 0, and has points 2,4,6,8,etc.

Question:

Should I be seeing two waves? If yes, how do I combine it into one? If no, what step might have I destroyed?

From my cloudy knowledge, the only thing I can think of that can explain this is the notion of imaginary and real numbers. But, I do not see why they should be shown in a time domain, after an iFFT occurs.

Fusho
  • 421
  • 3
  • 9
angryip
  • 283
  • 3
  • 10
  • If the data foes from 54 to 254, that is 151 samples actually.
  • When you plot the FFT, is it only the real part? imaginary part? I bet it is the real part only.
  • You are not seeing two waves, it is the same at very high frequency.
  • – Fusho May 31 '17 at 15:58
  • Sorry, from 54 to 204 (both included) there are 151 samples. – Fusho May 31 '17 at 16:05
  • @oxuf wrt to #1, my mistake, 54 to 203. wrt to #2, that is correct, it is only the real wrt to #3, I am not sure i understand what you mean. Are you saying that it is normal to see two identical waves, just one all the way up top and the other on the bottom? – angryip May 31 '17 at 18:56