Académique Documents
Professionnel Documents
Culture Documents
Today in DSP
The Discrete Time Fourier Transform
Examples Computing DTFT in Matlab
Recall
Quick facts: Since x[n] discrete, X() is obtained as an infinite sum of discrete components Since the term in the exponential is a continuous variable, DTFT X() is continuous (non-discrete) function. Since X() is continuous, x[n] is obtained as a continuous integral of X(), weighed by the same complex exponentials. DTFT is periodic with 2 in frequency domain. Hence frequencies 0 and 2 are identical, both correspinding to the same X ( ) = x[n]e jn zero frequencies. n = Discrete frequencies around 0 or 2 are low frequencies, whereas those around - to are high frequencies. We often plot DTFT on a 2 long interval, typically - to . The sampling frequency of s=2fs used to discretize the original signal corresponds to the discrete frequency of =2. Since the highest frequency allowed in a signal is half of sampling frequency, the highest frequency in any given signal is then radians. This is also why we typically plot DTFT in this interval. DTFT exists if the signal is absolutely summable. This is a sufficient condition, bit not required. There are some signals that are not absolutely summable whose DTFT exist. DTFT is a complex transform. Its absolute value provides how much energy of what frequency exists in the signal, where its angle tells us which frequencies are delayed by how much.
1 x[n] = X ( )e jt d 2
( 2m )
[ n] 1
x[n] = u[n]
n
1 1 e j
x[n] = cos(0 n )
m =
( 2m 0 ) + ( 2m + 0 )
m =
x[n] = e j0 n 2
m =
( 2m 0 )
e j n =
sin (M + 1 2 ) , 0 sin ( 2 )
ak y[n k ] = bl x[n l ],
l =0
a0 = 1
ak Y ( ) e
j k
l =0
bl X ( )e
M
j l
Y ( ) ak e
k =0
j k
= X ( ) bl e jl
l =0
Y ( ) = H ( ) = l = 0 N X ( ) a k e j k
k =0
bl e jl
If all ak (except a0) are zero, then the system defined by H() is an FIR filter. Otherwise, it an IIR filter.
DTFT in MATLAB
The difference equation representation is used in MATLAB to compute the DTFT of a signal or an impulse function.
H=freqz(num, den, w) [H, w]=freqz(num, den, k) [H, w]=freqz(num, den, k, whole) [H, f]=freqz(num, den, k, whole, Fs) [H, f]=freqz(num, den, f, Fs) [H, f]=freqz(num, den, k, Fs) Num, den: Numerator and denominator coefficients of the CCLDE H: the DTFT of the signal/system described by the CCLDE and computed around the unit circle w: the prescribed frequencies in radians at which H should be computed f: the prescribed frequencies in Hz at which H should be computed. 0<f<Fs/2 k: equally spaced points between 0 and , if H is to be computed at fixed number of kpoints. If whole is used, H corresponding to [0 ~ 2] or [0 ~ Fs] is computed.
Digital Signal Processing, 2005 Robi Polikar, Rowan University
DTFT in MATLAB
Other commands used along with freqz() are:
abs(x): computes the absolute value of x. If x is complex, it computes its magnitude. angle(x): computes the phase angle of x. If x is real, it the angle is zero. Real(x), imag(x): computes real and imaginary components of x unwrap(theta): Unwraps the angle theta so that artificial jumps at every 180 degrees are eliminated. impz(num, den, n, Fs): Computes the impulse response of the filter / system determined by the CCLDE coefficients num and den, using n points and assuming a sampling frequency of Fs. The time axis will then be n*T=n/Fs (seconds)
Sample Code
function [H, w]=my_dtft(num, den, k); %DTFT Computation %H: DTFT of the signal/system specified by the coefficients num and den %K: the number of DTFT coefficients desired, Fs: Sampling frequency w=0:pi/k:pi; H=freqz(num, den, w); subplot(221) plot(w/pi, real(H)); title(Real part); grid xlabel(\omega/\pi), ylabel(Amplitude) subplot(222) plot(w/pi, imag(H)); title(Imaginary part); grid xlabel(\omega/\pi), ylabel(Amplitude) subplot(223) plot(w/pi, abs(H)); title(Magnitude Spectrum); grid xlabel(\omega/\pi), ylabel(Magnitude) subplot(224) plot(w/pi, imag(H)); title(Phase spectrum); grid xlabel(\omega/\pi), ylabel(Phase, radians)
Sample Code
function [H, f]=my_dtft2(num, den, k, Fs); %DTFT Computation %H: DTFT of the signal/system specified by the coefficients num and den %K: the number of DTFT coefficients desired, Fs: Sampling frequency [H f]=freqz(num, den, k, Fs, whole); subplot(221) plot(f, real(H)); title(Real part); grid xlabel(Frequency, Hz), ylabel(Amplitude) subplot(222) plot(f, imag(H)); title(Imaginary part); grid xlabel(Frequency, Hz), ylabel(Amplitude) subplot(223) plot(f, abs(H)); title(Magnitude Spectrum); grid xlabel(Frequency, Hz), ylabel(Magnitude) subplot(224) plot(f, imag(H)); title(Phase spectrum); grid xlabel(Frequency, Hz), ylabel(Phase, radians)