Discrete Signal Processing (DSP):
Discrete Time Fourier Transformation (DTFT)
Table of Contents
The Discrete-Time Fourier Transform (DTFT) provides a frequency-domain representation for infinite-length discrete-time signals and systems. While the DFT is computationally convenient for finite-length signals, the DTFT is conceptually useful for analyzing infinite-duration signals.
Since both the time-domain signal $x[n]$ and its DFT $X[k]$ are periodic with period $N$, it is often convenient to center the range of indices around zero:
The centered (unnormalized) forward and inverse DFT formulas become:
To derive the DTFT, we examine the behavior of the DFT as $N \rightarrow \infty$:
Key fact: No matter how large $N$ grows, the frequencies of the DFT sinusoids always lie within the fixed interval:
Forward DTFT
In the limit as $N \rightarrow \infty$, the DFT becomes the DTFT:
This defines the inner product between the signal $x[n]$ and the complex exponential $e^{j\omega n}$.
$X(\omega)$ measures the similarity of $x[n]$ to the sinusoid $e^{j\omega n}$.
Inverse DTFT
The corresponding inverse transform reconstructs $x[n]$ from $X(\omega)$:
The DTFT pair is:
This formulation extends the DFT to a continuous, aperiodic setting, providing a foundational tool for analyzing infinite-length signals and linear time-invariant (LTI) systems.
(MATLAB Code) DTFT
%plot -s 560,300
% dtft from definition
n = 0:3;
x = [1 1 1 1];
N = 200;
w = [0:N-1]*2*pi/N;
Xdtft = 1*exp(-1j*w*0) + 1*exp(-1j*w*1) + 1*exp(-1j*w*2) + 1*exp(-1j*w*3);
plot(w/pi, abs(Xdtft))
xlabel('\omega in \pi unit', 'fontsize', 8),
title('DTFT in (0, 2\pi)', 'fontsize', 8)
(MATLAB Code) Centered DTFT
k = [0:N/2-1 -N/2:-1];
w = k*2*pi/N;
ws = fftshift(w);
Xdtfts = fftshift(Xdtft);
plot(ws/pi, abs(Xdtfts))
xlabel('\omega in \pi unit', 'fontsize', 8),
title('DTFT in (-\pi, \pi)', 'fontsize', 8)
x = [1,1,1,1];
N = length(x);
k = [0:N/2-1 -N/2:-1];
ks = fftshift(k);
X = dft(x,N);
Xs = fftshift(X);
stem(ks,abs(Xs),'filled'),
xlabel('freq in k','fontsize',8), ylabel('X[k]','fontsize',8),
xlim([-N/2,N/2]), hold on
c = [0 0.4470 0.7410];
plot(ws*N/(2*pi),abs(Xdtfts),'--', 'color', c), hold off
x = [1,1,1,1,zeros(1,4)];
N = length(x);
k = [0:N/2-1 -N/2:-1];
ks = fftshift(k);
X = dft(x,N);
Xs = fftshift(X);
stem(ks,abs(Xs),'filled'),
xlabel('freq in k','fontsize',8), ylabel('X[k]','fontsize',8),
xlim([-N/2,N/2]), hold on
plot(ws*N/(2*pi),abs(Xdtfts),'--', 'color', c), hold off
x = [1,1,1,1,zeros(1,12)];
N = length(x);
k = [0:N/2-1 -N/2:-1];
ks = fftshift(k);
X = dft(x,N);
Xs = fftshift(X);
stem(ks,abs(Xs),'filled'),
xlabel('freq in k'), ylabel('X[k]'), xlim([-N/2,N/2]), hold on
plot(ws*N/(2*pi),abs(Xdtfts),'--', 'color', c), hold off
% DTFT using the output of FFT (or DFT)
x = [1,1,1,1,zeros(1,2^6-4)];
N = length(x);
k = [0:N/2-1 -N/2:-1];
ks = fftshift(k);
X = dft(x,N);
Xs = fftshift(X);
stem(ks,abs(Xs),'filled')
xlabel('freq in k'), ylabel('X[k]'), xlim([-N/2,N/2]), hold on
plot(ws*N/(2*pi),abs(Xdtfts),'--', 'color', c), hold off
% DTFT using the output of FFT (or DFT)
x = [1,1,1,1,zeros(1,2^7-4)];
N = length(x);
k = [0:N/2-1 -N/2:-1];
ks = fftshift(k);
X = dft(x,N);
Xs = fftshift(X);
stem(ks,abs(Xs),'filled')
xlabel('freq in k'), ylabel('X[k]'), xlim([-N/2,N/2]), hold on
plot(ws*N/(2*pi),abs(Xdtfts),'--', 'color', c), hold off
function X = dtft(x,n,w)
% X = dtft(x, n, w)
%
% X = DTFT values computed at w frequencies
% x = finite duration sequence over n (row vector)
% n = sample position vector
% w = frequency location vector (row vector)
X = exp(-1j*(w'*n))*x';
end
DTFT of the Impulse
The impulse signal contains all frequency components with equal weight.
%plot -s 560,420
[x, n] = impseq(0, -10, 10);
w = linspace(-1,1,2^10)*pi;
X = dtft(x,n,w);
subplot(2,1,1),
stem(n,x,'filled')
subplot(2,1,2),
plot(w/pi,abs(X),'linewidth',2), ylim([0, 1.3])
xlabel('Freq. in \pi units')
DTFT of $e^{j\omega_0 n}$
This follows from:
DTFT of the Unit Pulse
Let:
Then the DTFT is:
%plot -s 560,420
x = [1 1 1 1 1 1 1];
n = -3:3;
w = linspace(-2,2,2^10)*pi;
X = dtft(x,n,w);
xd = zeros(1,31);
nd = -15:15;
[y,ny] = sigadd(xd,nd,x,n);
subplot(2,1,1), stem(ny,y,'filled')
subplot(2,1,2), plot(w/pi,abs(X)), xlabel('Freq. in \pi units')
DTFT of a Triangle Function
Define the triangle function as the convolution of two pulses:
Then, in the frequency domain:
This result shows that the triangle has stronger low-pass behavior than the rectangular pulse.
%plot -s 560,420
x = [1 2 3 4 3 2 1];
n = -3:3;
w = linspace(-2,2,2^10)*pi;
X = dtft(x,n,w);
xd = zeros(1,31);
nd = -15:15;
[y,ny] = sigadd(xd,nd,x,n);
subplot(2,1,1), stem(ny,y,'filled')
subplot(2,1,2), plot(w/pi,abs(X)), xlabel('Freq. in \pi units')
DTFT of a One-Sided Exponential
Let:
Then its DTFT is:
This is the DTFT of a causal, exponentially decaying signal. It exhibits a low-pass characteristic when $\alpha$ is real and positive.
%plot -s 560,600
N = 30;
x = zeros(1,N);
for i = 1:N
x(i) = 0.8^(i-1);
end
n = 0:N-1;
w = linspace(-2,2,2^10)*pi;
X = dtft(x,n,w);
nd = -8:N;
xd = zeros(size(nd));
[y,ny] = sigadd(xd,nd,x,n);
subplot(3,1,1), stem(ny,y,'filled'), xlabel('n')
subplot(3,1,2), plot(w/pi,abs(X)), ylabel('|X(\omega)|')
subplot(3,1,3), plot(w/pi,phase(X)), xlabel('Freq. in \pi units'), ylabel('\angle X(\omega)')
DTFT and Modulation
The modulation property describes how multiplying a signal by a complex exponential in time shifts its frequency content.
This means that modulation by $e^{j\omega_0 n}$ in the time domain shifts the DTFT by $\omega_0$ in the frequency domain.
Special case: When $\omega_0 = \frac{2\pi}{N}\frac{N}{2}=\pi$, the modulation becomes:
and the frequency shift becomes:
This flips the frequency spectrum around $\omega = 0$, effectively swapping low and high frequencies.
%plot -s 560,600
N = 30;
nd = -8:N;
xd = zeros(size(nd));
x = zeros(1,N);
for i = 1:N
x(i) = (-0.8)^(i-1);
end
n = 0:N-1;
%w = linspace(-1,1,2^10)*pi;
w = linspace(-2,2,2^10)*pi;
X = dtft(x,n,w);
subplot(3,1,1), stem(nd,sigadd(xd,nd,x,n),'filled'), xlabel('n')
subplot(3,1,2), plot(w/pi,abs(X)), ylabel('|X(\omega)|')
subplot(3,1,3), plot(w/pi,phase(X)), xlabel('Freq. in \pi units'), ylabel('\angle X(\omega)')
DTFT and Time Shift
This means a shift in time by $m$ samples results in a linear phase shift in the frequency domain, without changing the magnitude of the spectrum.
This phase shift corresponds to a rotation in the complex plane that increases linearly with frequency.
%plot -s 560,600
N = 30;
nd = -8:N;
xd = zeros(size(nd));
x = zeros(1,N);
for i = 1:N
x(i) = 0.8^(i-1);
end
m = 1;
n = 0+m:N-1+m;
[y,ny] = sigadd(xd,nd,x,n);
w = linspace(-2,2,2^10)*pi;
X = dtft(x,n,w);
subplot(3,1,1), stem(ny,y,'filled'), xlabel('n')
subplot(3,1,2), plot(w/pi,abs(X)),
subplot(3,1,3), plot(w/pi,phase(X)), xlabel('Freq. in \pi units')
DTFT and Convolution
Convolution in the time domain corresponds to multiplication in the frequency domain:
This property is fundamental in signal processing, enabling filtering operations to be performed as simple pointwise multiplication in the frequency domain.
A filter is a system that modifies or processes a signal to achieve a desired effect, often by enhancing certain components and suppressing others. In discrete-time signal processing, filters are implemented using convolution:
where:
Frequency-Domain View
Filtering becomes particularly intuitive in the frequency domain:
This means the output is obtained by multiplying the signal's spectrum $X(\omega)$ with the filter's frequency response $H(\omega)$. This operation allows us to:
Types of Filters
Filters are typically classified by their frequency-selective behavior:
Each filter is designed by specifying $h[n]$ (impulse response), which determines $H(\omega)$ via the DTFT.
A low-pass filter is designed to preserve the low-frequency components of a signal while attenuating the high-frequency components. This frequency-selective behavior is central in applications such as noise reduction and signal smoothing.
Consider a simple example with the following impulse response:
This defines a two-tap filter that performs local averaging across adjacent time samples.
(1) Impulse Response
This time-domain structure implies a smoothing operation in the output signal, as each output sample is an average of two consecutive input samples.
(2) Frequency Response
The Discrete-Time Fourier Transform (DTFT) of $h[n]$ is computed as:
The corresponding magnitude response is:
This function is maximal at $\omega = 0$ and decreases as $\omega$ approaches $\pm \pi$. Specifically:
Hence, the filter strongly attenuates high-frequency components while preserving the low-frequency content. This behavior is characteristic of a low-pass filter.
%plot -s 560,420
nd = -5:10;
hd = zeros(1,length(nd));
N = 2;
h = ones(1,N);
n = 0:N-1;
w = linspace(-1,1,2^10)*pi;
X = dtft(h,n,w);
[y,ny] = sigadd(hd,nd,h,n);
subplot(2,1,1), stem(ny,y,'filled')
subplot(2,1,2), plot(w/pi,abs(X)), xlabel('freq in \pi units')
A high-pass filter is designed to suppress low-frequency components of a signal while allowing high-frequency components to pass through. Such filters are useful for tasks like edge detection, signal differentiation, or removing slow-varying trends.
Consider the following impulse response:
This filter performs a differencing operation—measuring the change between adjacent signal samples.
(1) Impulse Response
This structure results in a difference operation between adjacent values, enhancing sharp transitions and removing slow or constant trends.
(2) Frequency Response
The DTFT of the impulse response is:
and the magnitude response is:
This function is minimal at $\omega = 0$ (where $|H(0)| = 0$) and maximal at $\omega = \pm \pi$ (where $|H(\pi)| = 2$). Therefore, the filter strongly attenuates low-frequency components while emphasizing high-frequency variations.
This behavior is characteristic of a high-pass filter.
%plot -s 560,420
nd = -5:10;
hd = zeros(1,length(nd));
N = 2;
h = [1 -1];
n = 0:N-1;
w = linspace(-1,1,2^10)*pi;
X = dtft(h,n,w);
[y,ny] = sigadd(hd,nd,h,n);
subplot(2,1,1), stem(ny,y,'filled')
subplot(2,1,2), plot(w/pi,abs(X)), xlabel('freq in \pi units')
A band-pass filter allows frequencies within a specified range to pass through while attenuating both low and high frequencies outside this band. Such filters are commonly used in communications and audio processing to isolate specific frequency components.
Consider the following impulse response:
This filter is a superposition of a low-pass component and a delayed, inverted low-pass component. It resembles a differenced average filter, which selectively enhances mid-range frequency content.
(1) Impulse Response
The symmetric structure with alternating signs hints at a band-selective behavior.
(2) Frequency Response
The DTFT of this impulse response is:
Though the exact closed form may be algebraically involved, the magnitude response shows a clear band-pass shape:
This demonstrates that the filter suppresses both the lowest and highest frequency components while passing those in the middle of the spectrum.
%plot -s 560,420
nd = -5:10;
hd = zeros(1,length(nd));
N = 4;
h = [1 1 -1 -1];
n = 0:N-1;
w = linspace(-1,1,2^10)*pi;
X = dtft(h,n,w);
[y,ny] = sigadd(hd,nd,h,n);
subplot(2,1,1), stem(ny,y,'filled')
subplot(2,1,2), plot(w/pi,abs(X)), xlabel('freq in \pi units')
The Second Example of Band-Pass Filter
(1) Impulse Response
Let the impulse response be:
This is a differencing filter with a gap of 2 samples, creating destructive interference at low and high frequencies while reinforcing energy around the middle frequencies.
(2) Frequency Response
The DTFT of this filter is:
and its magnitude response is:
This response:
This is the hallmark of a band-pass filter, with mid-frequency amplification and suppression of low and high frequencies.
%plot -s 560,420
nd = -5:10;
hd = zeros(1,length(nd));
N = 3;
h = [1 0 -1];
n = 0:N-1;
w = linspace(-1,1,2^10)*pi;
X = dtft(h,n,w);
[y,ny] = sigadd(hd,nd,h,n);
subplot(2,1,1), stem(ny,y,'filled')
subplot(2,1,2), plot(w/pi,abs(X)), xlabel('freq in \pi units')
The ideal low-pass filter perfectly passes all frequency components in the interval $[-\omega_c, \omega_c]$ and completely suppresses all others. It is defined by the frequency response:
This filter retains only the low-frequency content near $\omega = 0$ and removes high-frequency oscillations.
To obtain the corresponding impulse response $h[n]$, we compute the inverse DTFT:
This evaluates to:
Therefore, the complete impulse response is:
This is a scaled sinc function, and represents the ideal low-pass filter in discrete time.
MATLAB Note
MATLAB defines the normalized sinc function as:
%plot -s 560,600
wc = pi/6;
N = 30;
n = -N:N;
h = zeros(1,length(n));
for i = 1:length(n)
h(i) = 2*wc*sinc(1/pi*wc*(i-N-1));
end
w = linspace(-1,1,2^10)*pi;
X = dtft(h,n,w);
subplot(2,1,1), stem(n,h,'filled','markersize',4), ylabel('x[n]')
subplot(2,1,2), plot(w/pi,abs(X)), ylabel('X(\omega)')
xlabel('Freq. in \pi units'), ylabel('X(\omega)')
%plot -s 560,600
wc = pi/6;
N = 100;
n = -N:N;
h = zeros(1,length(n));
for i = 1:length(n)
h(i) = 2*wc*sinc(1/pi*wc*(i-N-1));
end
w = linspace(-1,1,2^10)*pi;
X = dtft(h,n,w);
subplot(2,1,1), stem(n,h,'filled','markersize',4), ylabel('x[n]')
subplot(2,1,2), plot(w/pi,abs(X)), ylabel('X(\omega)')
xlabel('Freq. in \pi units'), ylabel('X(\omega)')
Impulse Response of the Ideal High-Pass Filter
An ideal high-pass filter is designed to pass high-frequency components while attenuating low frequencies. Its frequency response is the complement of an ideal low-pass filter:
Rather than computing its inverse transform directly, we can relate the impulse response of the ideal high-pass filter, $h_H[n]$, to that of the ideal low-pass filter, $h_L[n]$.
The ideal high-pass filter can be obtained by modulating the ideal low-pass filter by $\pi$ radians:
This modulation effectively shifts the frequency response of the low-pass filter from being centered at $\omega = 0$ to being centered at $\omega = \pi$, thereby creating a high-pass response.
%plot -s 560,600
wc = pi/6;
N = 30;
n = -N:N;
d = zeros(1,length(n));
h = zeros(1,length(n));
d(N+1) = d(N+1) + 1;
for i = 1:length(n)
h(i) = (-1)^(i-N-1)*2*wc*sinc(1/pi*wc*(i-N-1));
end
w = linspace(-1,1,2^10)*pi;
X = dtft(h,n,w);
subplot(2,1,1), stem(n,h,'filled','markersize',4), ylabel('x[n]')
subplot(2,1,2), plot(w/pi,abs(X)), ylabel('X(\omega)')
xlabel('Freq. in \pi units'), ylabel('X(\omega)')
Consider the signal:
This signal contains two sinusoids with closely spaced frequencies near $\omega = \pi$.
N = 100;
n = 0:N-1;
x = cos(0.48*pi*n) + cos(0.52*pi*n);
Use 100 Samples of $x[n]$
We begin by generating 100 samples of $x[n]$. The frequency difference between the two components is small ($0.04\pi$), so we need sufficient time-domain data to resolve both components in the frequency domain.
%plot -s 560,420
k = n;
X = dft(x,N);
w = 2*pi/100*k;
subplot(2,1,1), stem(n,x,'filled')
subplot(2,1,2), stem(w/pi,abs(X),'filled')
Compute only the First 10-Point DFT
Suppose we compute a 10-point DFT using the first 10 samples from the 100-point sequence. This results in a very coarse frequency resolution. The frequency bins are widely spaced:
This is too coarse to distinguish between the two closely spaced sinusoids, which will appear merged or indistinct.
%plot -s 560,420
n1 = 0:9;
y1 = x(1:10);
Y1 = dft(y1,10);
k1 = n1;
w1 = 2*pi/10*k1;
subplot(2,1,1), stem(n1,y1,'filled')
subplot(2,1,2), stem(w1/pi,abs(Y1),'filled')
Zero-Padding to Increase Density
To obtain a denser spectrum, we pad the 10-point sequence with 90 zeros, forming a 100-point sequence. The resulting 100-point DFT provides a smoother, interpolated view of the spectral content.
%plot -s 560,420
n2 = 0:N-1;
y2 = [x(1:10), zeros(1,90)];
Y2 = dft(y2,N);
k2 = n2;
w2 = 2*pi/100*k2;
subplot(2,1,1), stem(n2,y2,'filled')
subplot(2,1,2), stem(w2/pi,abs(Y2),'filled')
Key Insight
Conclusion:
Padding with zeros to create a high-density spectrum improves the visual smoothness but does not enhance frequency resolution. It does not reveal new frequency content or allow better separation of closely spaced components.
%%javascript
$.getScript('https://kmahelona.github.io/ipython_notebook_goodies/ipython_notebook_toc.js')