Continue to Site

# compute samples of DTFT finite length signal

Status
Not open for further replies.

#### scdoro

##### Member level 5
The following MATLAB function can be used to compute samples of the DTFT of a
finite length signal.

Qn1) Can someone explain how this function works line by line?

**********************************************
Function [H,W] = dtft(x, n)
% Calculates DTFT of x at n equally spaced frequencies
% Usage:
% x: finite-length input vector (of length L)
% n: number of frequencies for evaluation over
% [-pi,pi]. n>=L.
% H: DTFT values
% W: vector of frequencies where DTFT is computed.
n=fix;
L=length(x); h=h)
if (n < L)
error(‘DTFT: #data samples cannot exceed # freq samples.’)
end
W = (2*pi/n) * [0n-1)]’;
mid = ceil(n/2) + 1;
W(mid:n) = W(mid:n) – 2*pi;
W = fftshift(W);
H = fftshift( fft(h,n) );

**********************************************************

Qn2) plot the magnitude and phase responses of the signal xn, given by

a = 0.88 * exp( j*2*pi/5 );
nn = 0:40;
xn = a.^nn;
for n = 128.

Qn3) Where is the peak of the frequency response.and why are there “jumps” in the phase response plot?

Status
Not open for further replies.