0

I am calculating frequency bin index k with formula

k = f_k * N / Fs + 1,

where sample rate is Fs, the number of samples in the FFT is N, then the frequency of the bin with Matlab index k is f_k. But I get that k is decimal number, and it needs to be integer because I use it later like index for Fourier transformed series. I don't know what to do?

Paul R
  • 208,748
  • 37
  • 389
  • 560
nick_name
  • 161
  • 10

2 Answers2

2

Each bin represents a range of frequencies (the width of each bin is Fs / N). The bin which corresponds to your frequency of interest is round(f_k * N / Fs) (+ 1 if you're using MATLAB's 1-based indexing), i.e. this is where most of your signal energy will appear, although there will be some energy in adjacent bins too, due to spectral leakage (you should of course use a window function to minimise this).

Further reading: How do I obtain the frequencies of each value in an FFT?.

Community
  • 1
  • 1
Paul R
  • 208,748
  • 37
  • 389
  • 560
0

All you need to do is convert k to an integer using round. You will have to recalculate your other variables for them to adjust to the integer value of k. I do not see how this could bother you too much.

Digital signal processing is based on a lot of approximation anyways.

Hope that helps out

Patrick
  • 3
  • 3