I'm trying to create a spectrogram of a complex signal 'y', but I'm running into a problem where the spectrogram that I create appears to have its spectral features "displaced" in frequency space, and I think that it has something to do with not having pre-processed the signal correctly.

I know the signal's:
sampling rate (Fs = 400 KHz)
bits/sample (Nbits = 16)
frequency that the signal is centered on (Fc = 5.60 MHz)
total time that the signal elapses (dT ~ 145 sec).

I tried to use matlab's built-in spectrogram function with the following arguments:
[S, F, T] = spectrogram(y, num_pts_win, num_pts_overlap, num_pts_fft, Fs);
num_pts_win = num_pts_fft = 2^14
num_pts_overlap = 1/2 num_pts_win = 2^13

After subtracting Fs/2 from F to get a frequency axis from -Fs/2 -> Fs/2 rather than from 0->Fs, I plotted the spectrogram of the log(S) and obtained: my spectrogram

while I was expecting to get something like this: correct spectrogram

I believe that this displacement of the spectral features has resulted from not accounting for the central/carrier frequency (Fc) anywhere, but as I'm sort of new at this, I don't really understand exactly how I should account for it.

Edit 1:

To clarify, I suspect that the spectral features I'm seeing in the first graph are actually aliases of the true spectral features, and I think this aliasing is happening because I haven't accounted for the central/carrier frequency.

Edit 2: After FFTSHIFT'ing over the frequency dimension I think I've cleaned things up nicely! spectrogram after fftshift'ing


1 Answer 1


After subtracting Fs/2 from F to get a frequency axis from -Fs/2 -> Fs/2 rather than from 0->Fs

You can't center the frequency by changing the labels on the x-axis. Use 'fftshift' instead.

  • $\begingroup$ I think that this fixes my issue, when I FFTSHIFT over the freq dimension AND re-center the frequency axis I get something that looks much closer to the spectrogram that I expected. Thanks! $\endgroup$
    – ACN
    Oct 29, 2013 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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