3
$\begingroup$

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.

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?

$\endgroup$

closed as unclear what you're asking by Peter K. Jan 21 '14 at 17:07

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ I think you meant to say that $f_s$ = 500, not $1/500$. $\endgroup$ – Phonon Oct 28 '13 at 5:16
  • $\begingroup$ 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. $\endgroup$ – Jazzmaniac Nov 10 '13 at 11:12
  • $\begingroup$ @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. $\endgroup$ – Jazzmaniac Nov 10 '13 at 15:12
  • $\begingroup$ 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. $\endgroup$ – Jazzmaniac Nov 13 '13 at 10:20
  • $\begingroup$ 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? $\endgroup$ – Peter K. Jan 21 '14 at 18:37
5
$\begingroup$

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.

$\endgroup$
5
+50
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ @freak_warrior, let me know what remains unclear after reading en.wikipedia.org/wiki/Beat_(acoustics) $\endgroup$ – Jazzmaniac Nov 2 '13 at 18:23
  • $\begingroup$ @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. $\endgroup$ – Jazzmaniac Nov 6 '13 at 9:28
  • $\begingroup$ 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. $\endgroup$ – Jazzmaniac Nov 10 '13 at 18:38
  • $\begingroup$ 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. $\endgroup$ – Jazzmaniac Nov 12 '13 at 9:00
  • $\begingroup$ @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. $\endgroup$ – Jazzmaniac Nov 13 '13 at 10:22
4
$\begingroup$

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.

enter image description here


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)
        padding = window_length - length(k:last_index);
        disp(padding)
        X = [X; k];
        Z = [Z; fftshift(abs(fft([x(k:last_index) zeros(1,padding)])))];
    end

    subplot(2,2,figNo);
    figNo = figNo + 1;
    contour(T(X),Y,Z,4,flag=[2,0,4])
    title("Window Length = " + string(window_length) )
    xlabel('Time');
    ylabel("Frequency (Hz)")
    //plot3d(X,Y,Z/max(Z)*10,alpha=60,theta=50,flag=[2,3,0],ebox=[0 N -fs/2 fs/2 0 10])
end
$\endgroup$
  • 1
    $\begingroup$ Oh wow, sweet plots! = ) $\endgroup$ – Phonon Nov 15 '13 at 18:15

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