%
% Filename: example16.m
%
% Description: M-file for investigating the effect of discrete-time
% signal truncation on the DFT.
%
N = [8 11 14 16]; % number of data points in truncated DT
% signal
for m = 1:4, % compute DFT of four truncated signals
n = 0:N(m)-1; % DT values for truncated signal
x = cos(pi*n/2); % truncated DT signal
Xk = dft(x); % compute DFT of truncated DT signal
subplot(2,2,m); % plot magnitude spectrum
stem(n*2*pi/N(m),abs(Xk),'filled');
xlabel('\Omega '); ylabel('|X_k|');
ttl = ['DFT of cos(\pin/2) for n=0,..,',num2str(N(m)-1)];
title(ttl);
end;
MATLAB Plot Generated: