Code covered by the BSD License  

Highlights from
MatLab Solutions: "Introduction to Digital Signal Processing: A Computer Laboratory Textbook".

image thumbnail

MatLab Solutions: "Introduction to Digital Signal Processing: A Computer Laboratory Textbook".

by

 

29 Oct 2012 (Updated )

These files are the MatLab solutions of exercises contained in the above DSP lab textbook.

my_DTFT(x,n)
function [w X] = my_DTFT(x,n)
% DTFT Computation using the definition formula.
%
% Input Arguments:
% x[n] : the discrete time signal whose DTFT is to be computed.
%     n : a vector that contains the time indices (i.e. the domain) of x[n].
%
%Output Arguments:
% 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 contained in w.
% 
% Caution: The output vectors w and X are (2*NSamples+1)-point long. 
% Make sure input vector x is a row vector.
x = x(:).';

% 2^10 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
      W = exp(-1i*w(k)*n);
      X(k) = W*x.';
end


Contact us