% Short demo script to show interpolation problem in frequency sampling filters
% This version shows effect of transition sample

% 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 11/3/97 - rms


N = 17;
N1 = 5;



% Set up initial DFT coefficient array:

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



% The main frequency sampling loop - first zero sample is varied
for v  = 0:.1:1,	% v = value of transition sample
	X(N1+1) = v;


% 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')
stem((2/N)*(N1),X(N1+1),'g')	% Highlight transition sample in green

hold off
xlabel('\omega/\pi','fontsize',14)
ylabel('|X(e^j^\omega)|','fontsize',14)
is = num2str(v);

title(['Transition sample = ',is],'fontsize',14)

pause
end
