Vous êtes sur la page 1sur 10

DTFT & Matlab Review

Digital Signal Processing, 2005 Robi Polikar, Rowan University

Today in DSP
The Discrete Time Fourier Transform
Examples Computing DTFT in Matlab

Digital Signal Processing, 2005 Robi Polikar, Rowan University

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

Digital Signal Processing, 2005 Robi Polikar, Rowan University

Important Properties of DTFT


We will study the following properties of the DTFT:
Linearity DTFT is a linear operator Time reversal x[n] X(-) Time shift x[n-n0] X()e-jn Frequency shift x[n] e-j n X(- 0) Convolution in time x[n]*y[n] X().Y() Convolution in frequency Differentiation in frequency nx[n] j (dX()/d) Parsevals theorem Conservation of energy in time and frequency domains For real valued of x[n], X() is conjugate symmetric, i.e., X(-)= X*(). This is why plotting only one half of the spectrum, typically from 0 to , in adequate.
0 0

Digital Signal Processing, 2005 Robi Polikar, Rowan University

Gotta Know DTFT Pairs


1 2
m =

( 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 )

1, M n M x[n] = rect M [n] = 0, otherwise


n=M

e j n =

sin (M + 1 2 ) , 0 sin ( 2 )

Digital Signal Processing, 2005 Robi Polikar, Rowan University

Difference Equations and The DTFT


Recall that a system can be characterized either by the impulse response h[n], or the CCLDE: y[n] + a1 y[n 1] + a2 y[n 2] + aN y[n N ] = b0 x[n] + b1x[n 1] + + bM x[n M ]
k =0

ak y[n k ] = bl x[n l ],
l =0

a0 = 1

Take DTFT of each side:


k =0

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.

Digital Signal Processing, 2005 Robi Polikar, Rowan University

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)

Digital Signal Processing, 2005 Robi Polikar, Rowan University

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)

Digital Signal Processing, 2005 Robi Polikar, Rowan University

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)

Digital Signal Processing, 2005 Robi Polikar, Rowan University

Vous aimerez peut-être aussi