I'm writing a Code for STFT in matlab and I am in the initial stage. Right now I have managed to do the FFT of a small chunk of a time signal. I used zero padding.

The problem I am facing is that after FFT there are 3500 bin frequencies. (In total there were 7000, I took half of them). My sampling frequency was 1000. So that equates 1 Bin = 10/35 Hz.

When I plot the data, I have the bin values in the X-Axis. In this was my Signal seems to have amplitudes in the 421st Bin or 60Hz.

How can I make my X-Axis such that it progresses by 10/35 and shows the spike in the correct place at 60 instead of 421. Thanks.

  • $\begingroup$ Welcome to DSP.SE! It's not clear for me what you are trying to achieve? Do you want to ensure that a 60 Hz tone shows a peak in the 60th bin? That probably won't happen: even if you had 1 bin = 1 Hz, you'd still have 60Hz turning up in the 61st bin. Can you please clarify what you're asking for? $\endgroup$ – Peter K. Nov 19 '15 at 13:10
  • $\begingroup$ Hey, Thanks for the reply. I was asking if I could change the notation in the axis in the Graph/Plot. The notation of the 421 bin should be 60. I want to represent the bins 0 to 3500 bins in the graph from 0 to 500. That way the figure will show the Spike and Say underneath it "60". $\endgroup$ – Rio1210 Nov 19 '15 at 13:15

Thanks for the clarification.

If you're currently doing


then you should do



x = linspace(0,1000,length(y));
| improve this answer | |
  • $\begingroup$ This did the trick. Can't believe I missed it though. Thanks. $\endgroup$ – Rio1210 Nov 19 '15 at 14:12
  • $\begingroup$ @Rio1210 : If it solved your problem, please give it the tick! :-) $\endgroup$ – Peter K. Nov 20 '15 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.