clear

ds=0.02;
wp=0.5;
ws=0.6;
wc=(wp+ws)/2;
x1=[wp,wp];
x2=[ws,ws];
y=[0,1+ds];
N=2^14;
w=linspace(0,2*pi,N);

M=;                 %%% find the minimum value of M that satisfies the specification
wd=;      %%% replace this with the actual window (rectwin, bartlett, hann or hamming)
                       %%% wd should be a row vector

n=0:1:M;
hd=wc*sinc(wc*(n-M/2));
hw=hd.*wd;
h=fft(hw,N);
plot(w/pi,abs(h),'LineWidth',3)
hold on
plot(w/pi,0*w+(1+ds),'r--',w/pi,0*w+(1-ds),'r--',w/pi,0*w+ds,'r--')
plot(x1, y,'r--',x2, y,'r--')
hold off
title(['Magnitude response with M = ', num2str(M)])
xlabel('Normalized Frequency (\times\pi rad/sample)')
ylabel('Magnitude')
ylim([0 1.1])
xlim([0,1])
grid on