% Short demo script to show interpolation problem in frequency sampling filters


% Parameters:
% 	N - size of DFT *** MUST BE ODD FOR PLOTS TO WORK OUT! ***
% 	N1 - how many nominal values are in passband (must < N/2)

% Last revised 10/31/97 - rms


N = 17;
N1 = 5;



% Set up and display initial DFT coefficient array:

X = [ones(1,N1) zeros(1,N-1-(2*(N1-1))) ones(1,N1-1)];

stem(0:N-1,X)
xlabel('k','fontsize',14)
ylabel('X[k]','fontsize',14)
pause



stem(X(1:(N+1)/2))
xlabel('k','fontsize',14)
ylabel('X[k]','fontsize',14)
pause

% Compute the time-domain coefficients
b = idft(X,N);
b2 = [b(1+((N+1)/2):N) b(1:(N+1)/2)];	% rotate

%Compute the DTFT
n = -(N-1)/2 : (N-1)/2;
w = 0:pi/100:pi;
[H] = dtft(b2,n,w);

stem((2/N)*(0:((N+1)/2)-1),X(1:(N+1)/2))
hold on
plot(w/pi,real(H),'r')
hold off
xlabel('\omega/\pi','fontsize',14)
ylabel('abs(X(e^jw))','fontsize',14)

pause

% Show magnitude in dB, too
plot(w/pi,20*log10(abs(H)),'r')
xlabel('\omega/\pi','fontsize',14)
ylabel('Magnitude in dB','fontsize',14)


