clear all
close all

N=2048;
n=0:24;
x=cos(0.2*pi*n);
X=fft(x,N);
m=-(N-1)/2:(N-1)/2;
plot(2*pi/N*m,fftshift(abs(X)))
title('rectangular window')

clear all
figure(2)
N=2048;
n=0:24;
x=cos(0.2*pi*n)+cos(0.22*pi*n)+cos(0.6*pi*n);
X=fft(x,N);
m=-(N-1)/2:(N-1)/2;
plot(2*pi/N*m,fftshift(abs(X)))
title('rectangular, L=25')

clear all
figure(3)
N=2048;
n=0:49;
x=cos(0.2*pi*n)+cos(0.22*pi*n)+cos(0.6*pi*n);
X=fft(x,N);
m=-(N-1)/2:(N-1)/2;
plot(2*pi/N*m,fftshift(abs(X)))
title('rectangular, L=50')

clear all
figure(4)
N=2048;
n=0:100;
x=cos(0.2*pi*n)+cos(0.22*pi*n)+cos(0.6*pi*n);
X=fft(x,N);
m=-(N-1)/2:(N-1)/2;
plot(2*pi/N*m,fftshift(abs(X)))
title('rectangular, L=100')

clear all
N=2048;
w=hanning(25);
n=0:24;
x=cos(0.2*pi*n);
X=fft(x'.*w,N);
m=-(N-1)/2:(N-1)/2;
plot(2*pi/N*m,fftshift(abs(X)))
title('Hanning window')

clear all
figure(3)
N=2048;
w=hanning(75);
n=0:74;
x=cos(0.2*pi*n)+cos(0.22*pi*n)+cos(0.6*pi*n);
X=fft(x'.*w,N);
m=-(N-1)/2:(N-1)/2;
plot(2*pi/N*m,fftshift(abs(X)))
title('Hanning, L=75')

clear all
figure(4)
N=2048;
w=hanning(100);
n=0:99;
x=cos(0.2*pi*n)+cos(0.22*pi*n)+cos(0.6*pi*n);
X=fft(x'.*w,N);
m=-(N-1)/2:(N-1)/2;
plot(2*pi/N*m,fftshift(abs(X)))
title('Hanning, L=100')
