# Why Matlab Spectrogram of slow and rarely sampled signal shows high frequencies

I have a signal, which was measured for 14.4 minutes (= 864 seconds). There are 192 measurements, so one measurement was done in every 4.5 seconds, which results in a 0.22 Hz sampling frequency if I am not mistaken. As far as I know, the highest frequency that could be seen on a spectrogram of this data should be 0.11 Hz, the Nyquist frequency. I would expect the spectrogram to have the y axis ranging from 0 and 0.11 Hz, but it looks like the axis is labeled between 0 and 110 mHz.

(And of course when I would like to zoom in to 0-2 Hz using the command "ylim([0 2]);" the axis changes to 0-2 mHz and shows vertical lines:)

Why is this happening? I would like to display the correct labels on y axis (and if possible, I would like to do this without manually changing the label texts to Hz, etc..). Am I doing something wrong?

The code looks something like this:

X = ... % timepoints (192)
Y = ... % values (192)

srate = 0.22; % one measurement in every 4.5 seconds = 0.22 hz

winsize = ceil(length(X)/10); % this equals to 20
pupdil = pupdil-mean(Y); % subtract the "DC component"

shift = ceil(length(X)/150); % this equals to 2

spectrogram(Y, rectwin(winsize), winsize-shift, winsize, srate, 'yaxis');


Spectrogram given by MATLAB is right. The frequency axis shows frequency from 0 to 110mHz which is equivalent to 0 to 0.110Hz. mHz stands for milli-Hertz. There is no problem with that plot.

Now the question is why we are seeing high energy components at all frequencies in the range 0 to 110mHz. That I think is because of the Aliasing effect. The sampling frequency is only 0.22Hz, and the original continuous-time signal must be having higher frequency components in it. Either the original signal must be LowPass Filtered to contain only components upto 110mHz before sampling, or the signal must be sampled much faster. This is one of the possible reason for what we are seeing in spectrogram plot.

• Thank you, I just misunderstood the "m" prefix in mHz! I thought it means megahertz.. I am just smiling at myself right now :) Yes, the original signal contains much higher frequencies, but this recording was only sampled at 0.22 Hz, so some information got lost in this case. Jul 27 '21 at 18:17
1. 0.11Hz is 110mHz
2. Vertical lines are due to the zoom; they're the bottom row ... zoomed:

This is a purely visual effect, no data is added. To make the data zoom between 0 and 2mHz, increase nfft, then zoom the spectrogram.

Why Matlab Spectrogram of slow and rarely sampled signal shows high frequencies

The highest frequency it's showing is 110mHz, which is low. The only way to tell what the actual highest frequency is (besides knowledge of the signal) is to increase the sampling rate; if high frequencies persist, then the lower sampling rate aliases.

Someone at Matlab chose the most idiotic defaults for x and y units as well as location of time axis in spectrogram().

Rather than fixing it, I just do [S, F, T] = spectrogram() and plot the results myself using imagesc() or pcolor() depending on if I want log axis or not.