scdoro
Member level 5
- Joined
- Jan 12, 2005
- Messages
- 87
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,286
- Activity points
- 1,040
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?
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?