Remap FFT frequency bin distribution

I've coded up the FFT for a dataset I'm working with. My intent is to create a waterfall plot of the result, but the problem I'm running into is if I change my input data size, then I get a different number of frequency bins. Currently I'm just making my input dataset twice the size of the number of pixels I need to map to. I'm trying to figure out a way to map the frequency bins of any data set size to a specific number of pixels. For example, mapping an array of 500 values to an array that is 1250 elements long. It would be nice to have the option to perform linear and non-linear interpolation on the data mapping. I also might need to go the other way, say to map the values to an array that is 300 elements long. I'm not a math major and am coming up with a blank on this one.

• It sounds to me like you're using FFT as a black box without regard to its intended application; I would guess (but I'm not an expert) that what you want to do is either very difficult or meaningless. If you explain clearly what you want to use your FFT for, it might help: note that there are many other types of data representation, and the FFT is not always the most suitable one to use. The choice of solution is strongly dependent on your intended application. Mar 8, 2011 at 4:55
• I'm designing a program that will allow me to listen to a drilling tool as it is breaking through solid rock and monitor the frequency spectrum of the rock response through an accelerometer. I'm trying to be able to identify different rock types/properties based on frequency content while drilling. Mar 9, 2011 at 15:39
• OK, thanks for explaining the background to the problem. But, unless you have a detailed physical model relating properties of the rock to properties of the Fourier transform, I don't see how this is a mathematical question. Suppose you had the exact Fourier transform available; how would you use that to make your decisions? Are you planning to try to judge by eye from the frequency graph? Does the same type of rock always give a similar frequency distribution? Otherwise, the FFT is not likely to be useful. Mar 11, 2011 at 6:36
• ...I suppose what I'm trying to say is that the uncertainties/errors/unknowns in your model and/or data sound like they could be far greater than anything arising from mathematical analysis of the data, so it's not worth worrying too much about the mathematical details until you have a better physical understanding. Mar 11, 2011 at 6:40
• ...if, on the other hand, there is no good model available, you could try using a statistical approach: collect masses and masses of data and try to get a computer to find patterns/correlations in the data. But I don't know how likely this is to succeed. Mar 11, 2011 at 7:22

1 Answer

Pick a large number of points to discretize the frequency domain with. When you have a time signal with less points zero pad until you hit that number. This is sometimes called "spectral interpolation" https://ccrma.stanford.edu/~jos/st/Zero_Padding_Theorem_Spectral.html and does a nice job of interpreting the frequency domain.