% EE 329: Windowing exercise
% Lab 4
% Rich Kozick, 1997

T = .01;
t = 0:T:1;
Fs = 1/T;
N = length(t);
f = (0:N-1)/N*Fs;

x1 = cos(2*pi*20*t);
x2 = sin(2*pi*25.5*t);

N1 = 512;
f1 = (0:N1-1)/N1*Fs;

y = x1 + 0.01*x2;
Y = fft(y,N1);

figure(1)
plot(t,y);
title('Time signal -- NO windowing')

z = y .* hanning(N)';
Z = fft(z,N1);

figure(2)
plot(t,z);
title('Time signal -- WITH windowing')

figure(3)
plot(f1, 20*log10(abs(Y)))
axis([0 100 -30 40])
title('FFT with NO windowing')
xlabel('f (Hz)')
ylabel('dB')

figure(4)
plot(f1, 20*log10(abs(Z)))
axis([0 100 -30 40])
title('FFT WITH windowing')
xlabel('f (Hz)')
ylabel('dB')
