MatLab Solutions: "Introduction to Digital Signal Processing: A Computer Laboratory Textbook".
29 Oct 2012
25 Nov 2013)
These files are the MatLab solutions of exercises contained in the above DSP lab textbook.
function [w X] = my_DTFT3(x,n1)
% DTFT Computation using the definition formula.
% Input Arguments:
% x[n] : the discrete time signal whose DTFT is to be computed.
% n1 : a vector that contains the time indices (i.e. the domain) of x[n].
% w : a vector containing a sampled version of the [-pi pi] digital frequency interval.
% X[k]: a vector containing the DTFT of x[n] computed at frequencies given in w.
% Caution: The output vectors w and X are (2*NSamples+1)-point long.
nmin = n1(1);
nmax = n1(end);
% 2^11 samples to describe the frequency interval (0,pi] are considered sufficient!
NSamples = 1024;
w = -pi:pi/NSamples:pi; % length(w) = length(X) = 2*NSamples + 1.
X = zeros(1,2*NSamples + 1);
for k = 1:2*NSamples + 1
for n = nmin:nmax
X(k) = X(k) + x(n+1-nmin)*exp(-1i*w(k)*n);