// draws magnitude frequency response of hamming window size 64

clear; //you have to clear variables before startng

x=-3.14:0.001:3.14;  

// x is input variable, a row vector x(0)=-pi, x(1)=-pi+0.001,...,x(n)=pi

pi = 3.1415926;

a = sin(32*x);
b = sin(x/2);

c = x-2*pi/63;
d = x+2*pi/63;

e = sin(32*c);
f = sin(c/2);

g = sin(32*d);
h = sin(d/2);

S = a./b;
S1 = e./f;
S2 = g./h;
 
z = (1/(0.54*64-0.46))*(0.54*S + 0.23*S1 + 0.23*S2);

y = 20*log10(z)

plot(x,y);

