% dtft_disp2.m
% Script that runs and displays results of DTFT operation
%
% n = vector of n values used for calculation
% x = vector of time function, same size as x
% w = vector of omega values, not normalized
% ndisp = vector of n values used for display, a subset of n
% X = DTFT values computed at w frequencies


[X] = dtft(x,n,w);

ndisplen = length(ndisp);
ndispbeg = ndisp(1)-n(1)+1;
ndispend = ndispbeg+ndisplen-1;
subplot(3,1,1),stem(ndisp,x(ndispbeg:ndispend))
xlabel('n')
ylabel('x[n]')
%nshiftdisp1 = num2str((-2*nshift-5));
%title(['x[n] = u[n',nlimitdisp,'] u[',nlimitdisp,'-n]'])
subplot(3,1,2),plot(w/pi,abs(X))
xlabel('omega/pi')
ylabel('|X|')
angX = angle(X);
for i = 1:length(angX),
	if angX(i) < -pi+.01
	angX(i)=angX(i)+2*pi;
	elseif angX(i) == -0
	angX(i) = 0;
	end
			
	end
	
	
subplot(3,1,3),plot(w/pi,angX)
xlabel('omega/pi')
ylabel('<X')
%axis([-2 2 -1  4])
