t = linspace(-5*pi,5*pi,1000);
x1 = cos(2*pi*5*t); x2 = cos(2*pi*10*t); x3 = cos(2*pi*20*t); x4 = cos(2*pi*50*t);
x1 = cos(2*t); x2 = cos(2*pi*t); x3 = cos(20*t); x4 = cos(50*t);
x = [x1(1:250) x2(251:501) x3(502:752) x4(753:1000)];
subplot(4,1,1); plot(x);
X = fftshift(fft(x));
subplot(4,1,2); plot(abs(X));
w = hamming(250)'; % weighting function
x = x .* [w w w w] / mean(w); % apply weighting to all four frequency bursts
subplot(4,1,3); plot(x,'color',[0 0.7 0]);
X = fftshift(fft(x));
subplot(4,1,4); plot(abs(X),'color',[0 0.7 0]);