# strange phenomenon in spectrogram of Windowed Fourier Transform [edited] [closed]

I am trying to understand how the Windowed Fourier transform works, so I used Matlab to create an artificial signal, and plotted the Windowed Fourier transform using a gaussian window.

$x(t) = \left\{\begin{matrix} \sin(2\pi100t)& \text{for }0\leq{t}<\frac{1}{4}\\ \sin(2\pi50t)& \text{for }\frac{1}{4}\leq{t}<\frac{1}{2}\\ \sin(2\pi25t)& \text{for }\frac{1}{2}\leq{t}<\frac{3}{4}\\ \sin(2\pi10t)& \text{for }\frac{3}{4}\leq{t}\leq1 \end{matrix}\right.$

and $f_s=500$, i.e. the data points are sampled at every 1/500 second.

This is what I have obtained for my plot.

However, for the last 2 intervals, $\frac{1}{2}\leq{t}<\frac{3}{4}$, and $\frac{3}{4}\leq{t}\leq1$, we can see some form of bifurcating phenomenon (vertically). Why is this so?

• I think you meant to say that $f_s$ = 500, not $1/500$. – Phonon Oct 28 '13 at 5:16
• If you think that there's not enough detail in the answers you got you should also try to ask more specifically for what you do not understand yet. I wouldn't know what aspect of the question to elaborate on unless you give detailed feedback. – Jazzmaniac Nov 10 '13 at 11:12
• @freak_warrior, I though that is what I did below. If you don't tell me which aspect remains unclear I don't see what I could add to that explanation. – Jazzmaniac Nov 10 '13 at 15:12
• It would be great if you could reply in the same comment thread and not jump threads. I posted my answer below where it belongs. – Jazzmaniac Nov 13 '13 at 10:20
• I have reverted the last edit which deleted the whole content of the post. The site (including two moderators!) has put too much effort into this to delete it. I have put it on hold, so that no further answers will be added. Why do you want to delete it? – Peter K. Jan 21 '14 at 18:37

This happens because your window is too short. I don't have access to a plotting tool right now, but imagine for a second a slowly varying sinusoid that you chop up into pieces, and these pieces are shorter than the period of your sinusoid. If you take the Fourier transform of each of these pieces, some of your chunks will capture more energy of this sinusoid than others because they will contain crest or through of the function, while others will contain regions close to 0.

If you increase your window size, you'll be able to catch several cycles of your slow sinusoids inside each window, and the periodicity will go away. The tradeoff is that your windows will capture larger lengths of time, so boundaries between events will be more blurred.

If this still doesn't make sense, I'll try to include some plots later.

In discrete signal processing the frequency domain axis topology is surprisingly not a straight line, but a closed circle. Therefore the upper and lower edge of your image are really "identified", meaning they are connected and direct neighbors. The modulation you're seeing is the beating of the two interfering components coming closer.

The window size has an effect on this as it controls the frequency resolution. If you take an (effectively) longer window, then the beating will be reduced because the fourier transforms of the window centered at the sinusoidal components' frequencies will overlap less.

• @freak_warrior, let me know what remains unclear after reading en.wikipedia.org/wiki/Beat_(acoustics) – Jazzmaniac Nov 2 '13 at 18:23
• @freak_warrior, not sure I understand what you're asking. The beating is the modulated envelope that you see for the last two sinusoidal bursts. – Jazzmaniac Nov 6 '13 at 9:28
• You can reduce the beating by taking a longer analysis window, like I wrote in my answer. But you can never eliminate the phenomenon of beating itself. If two sinusoids are close enough the frequency resolution of the spectrogram will not suffice to resolve them and they will start to beat. – Jazzmaniac Nov 10 '13 at 18:38
• The strength (and frequency) of the beating depends on the distance of the sinusoids in the frequency direction. If you increase the distance, the beating gets weaker and also faster, until it is both too fast and too weak to be noticed. And like I said in my answer, the top and bottom boundary of your spectrogram are really a shared edge, like in a cylinder. The two bars from the sinusoid's negative and positive frequency component are therefore very close together, and not far apart as one would think. – Jazzmaniac Nov 12 '13 at 9:00
• @freak_warrior, I said "bars from the sinusoids negative and positive frequency component", so it should be clear that I mean the horizontal bars. The vertical transient-like features are the result of the beating (on-off-on-off) modulation. – Jazzmaniac Nov 13 '13 at 10:22

To illustrate what both @Jazzmaniac and @Phonon are telling you, let's look at the same plot, but for different window lengths. Another change is to look at the plots using the fftshift view --- so that it's clearer that the low positive frequency peaks are close to the low negative frequency peaks.

The picture below plots the contour plot of the data you have (see scilab code below) for window lengths of 32, 64, 128 and 256. Even at the 256 window length, the effect of the "beating" is still somewhat present.

Code only below.

fs = 500;
t1 = [0:1/fs:(0.25-1/fs)]
t2 = [0.25:1/fs:(0.5-1/fs)]
t3 = [0.5:1/fs:(0.75-1/fs)]
t4 = [0.75:1/fs:(1-1/fs)]
T = [t1 t2 t3 t4];

x = [sin(2*%pi*100*t1) sin(2*%pi*50*t2) sin(2*%pi*25*t3) sin(2*%pi*10*t4)];

N = length(x);
figNo = 1;

figure(1)
clf
subplot(221)
xset("fpf","   ")
for window_length = 2.^[5:8];

Z = [];
X = [];
Y = (([1:window_length]-1)/window_length*fs - fs/2);
for k=1:10:N
last_index = min(N,k+window_length-1);
disp(last_index)
X = [X; k];