Transcript Chapter 4

Chapter 4
The Frequency Domain of Signals
and Systems
Objectives
•
•
•
•
•
•
•
•
•
Define the Fourier transform and explain some of its important properties.
Define the discrete-time Fourier transform (DTFT) and demonstrate that it gives its
maximum response at the digital frequencies contained in a discrete time-domain
signal.
Prove the three key properties of the DTFT: linearity, periodicity, and time-delay.
Demonstrate the replication of the frequency content of a signal at integer multiples
of the sampling frequency
Demonstrate the concept of signal windowing in spectral analysis and show how
different windows affect the resolution and side-lobe amplitudes of the DTFT.
Explain the limitations of the DTFT and the “uncertainty principle” in spectral analysis.
Define signal power and energy and demonstrate their methods of calculation in the
time domain and frequency domain.
Show how to simulate signals with random noise and demonstrate the spectral
properties of Gaussian noise power in discrete-time signals.
Derive the frequency response of a general linear time-invariant DSP system and
show that the frequency response is the value of the z-domain transfer function on
the unit circle in the complex plane.
Fourier’s Theorem
Fourier’s theorem states that any continuous periodic signal can be
represented by an infinite sum of harmonically related sinusoids.
a0 
s(t )     an cos(n0t )  bn sin(n0t 
2 n1
2 T
an   s(t ) cos(n0t )dt
T 0
2 T
bn   s(t )sin(n0t )dt
T 0
2 T
2 T
a0 =  s(t ) cos(0)dt   s(t )dt
T 0
T 0
s(t ) 

jn0t
c
e
 n
n 
1
cn 
T

T
0
s (t )e  jn0 dt
The coefficients (a,b,c) represent
the frequency content of the signal
at discrete frequencies.
The Fourier Coefficients of a Square Pulse Train
1
Tp
Tp
2
-w/2
w/2
Tp
2
Tp
t
The Fourier Coefficients of a Square Pulse Train
1
cn =
T
ò
T /2
s (t )e-
jnω0t
dt
- T /2
1
1 éê - 1 - jnω0t
=
e
dt =
e
ò
ê
w
/
2
Tp
Tp ë jnω0
ù
1 éê - 1
- jnπf 0 w
jnπf 0 w ú
=
e
- e
(
)ú
ê
Tp ë jn 2πf 0
û
æ1 ÷
öæ 1 öæe jnπf0 w - e- jnπf0 w ö
ç
÷
÷
çç
çç
÷
÷
= çç ÷
÷
÷
÷
ç
÷
÷
֍
ç
÷è nπf 0 øè
çèTp ø
2j
ø
w/ 2
æ1 ö
÷sin(nπf 0 w)
= ççç ÷
=
÷
÷
÷ nπf 0
çèTp ø
æw ÷
ö
ç
= çç ÷
sinc(nπf 0 w)
÷
÷
÷
çèTp ø
w/ 2
ù
jn 2 p f 0t ú
ú
û- w / 2
æw ö÷sin(nπf w)
çç ÷
0
÷
ç ÷ nπf w
èçTp ø÷
0
for - ¥ < n < ¥
Computational Analysis of a Square Pulse Train
(Custom M-file “pulse_train”)
>> w=1;
%Set the pulse width in ms
>> fmax=3500;
%Set the maximum harmonic frequency
>> R1=4;
%Set the period-to-width ratio for each case
>> R2=8;
>> R3=32;
>> [c1,f1]=pulse_train(fmax,w,R1); %Use the M-file to compute the
Fourier coefficients
>> [c2,f2]=pulse_train(fmax,w,R2); % Case 2
>> [c3,f3]=pulse_train(fmax,w,R3); % Case 3
>> subplot(3,1,1),stem(f1,c1),title('Period to Width Ratio = 4');
>> subplot(3,1,2),stem(f2,c2),title('Period to Width Ratio = 8');
>> subplot(3,1,3),stem(f3,c3),title('Period to Width Ratio = 32');
>> xlabel('Harmonic Frequency - Hz')
Period to Width Ratio = 4
0.5
0
-0.5
-4000
-3000
-2000
-1000
0
1000
2000
3000
4000
2000
3000
4000
2000
3000
4000
Period to Width Ratio = 8
0.2
0
-0.2
-4000
-3000
-2000
-1000
0
1000
Period to Width Ratio = 32
0.05
0
-0.05
-4000
-3000
-2000
-1000
0
1000
Harmonic Frequency - Hz
As the period-to-width
ratio increases the
frequency “density” of
the coefficients
increases. In the limit,
the coefficients
become a continuous
function of frequency.
Fourier Transform
• The pulse train analysis suggests that for a general non-periodic
signal, a continuous function of frequency represents the “frequency
content” of the continuous signal.
• Definition of the Fourier transform:
X (ω) =
F {x(t )} =
ò
¥
- ¥
ò
¥
- ¥
x(t )ex(t )e-
jωt
jωt
dt
dt
The Discrete-Time Fourier
Transform (DTFT)
X () 


n 
N 1
x[n]e jn   x[n]e jn
n 0
f
  2
fs
•
•
•
•
•
The DTFT is the Fourier transform for discrete-time signals
The DTFT requires a finite causal signal for a practical
calculation. Therefore, the result depends on signal length, N
The DTFT is a continuous complex function of Ω
Calculation of the DTFT requires N terms for a discrete Ω.
Thus, practical calculations require computer assistance.
Efficient computation of the DTFT is an important problem in
DSP (e.g., the FFT or “Fast Fourier Transform”)
Example Calculation
Calculate the DTFT for the signal x[n] = [1,-1,1,-1] at the digital frequencies of
π and π/2.
For Ω = π:
N 1
X ()   x[n]e
 jn
n 0
3
  x[n]e
 j n
n 0
3
3
n 0
n 0
  x[n]cos( n)  j sin( n)   x[n]cos( n)
 (1)(1)  (1)(1)  (1)(1)  (1)(1)
4
For Ω = π/2
N 1
X ()   x[n]e
n 0
 jn
3
  x[n]e
n 0
 j n / 2

 

  x[n] cos( n)  j sin( n) 
2
2 

n 0
3


3
3
 (1)[cos(0)  j sin(0)]  (1)[cos( )  j sin( )]  (1)[cos( )  j sin( )]  (1)[cos
 j sin( )]
2
2
2
2
 (1)(1)  (1)( j )  (1)(1)  (1)( j )
0
Example Calculation:
A Short Sinusoid at 3 Frequencies
>> n=0:7;
>> omega1=pi/2;
>> x=cos(omega1*n);
>> stem(n,x), title('8 Samples of a Sinusoid of Frequency pi/2')
>> xlabel('Index, n')
>> omega=[0,pi/2,pi];
% Our three values of Ω
>> X=[0,0,0]; % We initialize the vector for X
>> for k=1:3
% For each value of omega
>> for m=1:8
% For each value of the signal
% Compute the DTFT summation for the kth value of Ω
>> X(k)=X(k)+x(m)*exp(-j*omega(k)*(m-1));
>> end
>> end
>> figure,plot(omega/pi,abs(X))
>> title('Three Points of the DTFT')
>> ylabel('Magnitude of the DTFT')
>> xlabel('Digital Frequency in Units of Pi')
Example Calculation:
A Short Sinusoid at 3 Frequencies
8 Samples of a Sinusoid of Frequency pi/2
Three Points of the DTFT
1
4
0.8
3.5
0.6
3
Magnitude of the DTFT
0.4
0.2
0
-0.2
-0.4
2.5
2
1.5
1
-0.6
0.5
-0.8
-1
0
1
2
3
4
Index, n
5
6
7
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
Digital Frequency in Units of Pi
0.8
0.9
1
Example Calculation:
A Short Sinusoid at 512 Frequencies
• >> dtft_demo(x,0,pi,512); % Custom M-file
Discrete Time Fourier Transform
4
3.5
3
2.5
2
1.5
1
0.5
0
0
0.1
0.2
0.3
0.4
0.5
0.6
Units of Pi
0.7
0.8
0.9
1
Example Calculation:
A Long Sinusoid at 512 Frequencies
>> n=0:99; % create a signal with 100 samples
>> omega1=pi/2;
>> x=cos(omega1*n);
>> dtft_demo(x,0,pi,512);title('DTFT of a Sinusoid, Omega = pi/2, N = 100')
DTFT of a Sinusoid, Omega = pi/2, N = 100
50
45
40
35
30
25
20
15
10
5
0
0
0.1
0.2
0.3
0.4
0.5
0.6
Units of Pi
0.7
0.8
0.9
1
Properties of the DTFT
Linearity
• Suppose y[n] = x1[n] + x2[n]
Y () 


y[n]e jn 
n 



n 
x1[n]e

 jn
x
[
n
]

x
[
n
]
e


 1
2
n 
 jn



n 
x2 [n]e jn
 X 1 ()  X 2 ()
The DTFT of a linear combination of
signals is the same linear combination
of the DTFT’s of the individual signals.
Properties of the DTFT
Periodicity
X () 


x[n]e jn
n 
X (  2 k ) 


x[n]e  j (  2 k ) n
n 



x[n]e  jn e  j 2 kn
n 
but
e  j 2 kn  cos(2 kn)  j sin(2 kn)  1
so
X (  2 k ) 

 x[n]e
n 
 jn
 X ()
The DTFT is
periodic in the Ω
frequency domain
with period 2π
Properties of the DTFT
Time-Delay
Suppose the DTFT of x[n] is X(Ω) and the DTFT of x[n-k] is Xk(Ω)
X k ( ) 


x[n  k ]e  jn
n 
let :
m  nk
n  mk
then,
X k ( ) 



m 


x[m]e  j ( m  k ) 
m  k 
x[m]e  jm e  jk   e  jk  X ()
The DTFT of a
signal delayed by
k steps is e -jkΩ
times the DTFT of
the un-delayed
signal
Replication of Spectral Content in the Frequency
Domain (Periodicity of the DTFT)
>> [asig,tt]=analog([50,120],[1,0.5],500,32000);
>> d1000=sample(tt,asig,1000);
>> d2000=sample(tt,asig,2000);
>> dtft_demof(d1000,-500,500,512,1000);
>> figure,subplot(2,1,1), dtft_demof(d1000,0,8000,16*512,1000); title('Fs = 1000 Hz')
>> subplot(2,1,2), dtft_demof(d2000,0,8000,16*512,2000); title('Fs = 2000 Hz')
Fs = 1000 Hz
300
Discrete Time Fourier Transform
250
200
200
100
150
0
100
600
0
1000
2000
3000
4000
5000
Hz
Fs = 2000 Hz
0
1000
2000
3000
6000
7000
8000
6000
7000
8000
400
50
200
0
-500
-400
-300
-200
-100
0
Hz
100
200
300
400
500
0
4000
Hz
5000
Replication at integer multiples of the sampling frequency
Effects of Signal Length and Windowing
Frequency Resolution
>> N1=0:9;
>> N2=0:19;
>> N3=0:39;
>> omega=pi/2;
>> x1=cos(omega*N1);
>> x2=cos(omega*N2);
>> x3=cos(omega*N3);
>> [X1,f]=dtft_demo(x1,0,pi,512);
>> [X2,f]=dtft_demo(x2,0,pi,512);
>> [X3,f]=dtft_demo(x3,0,pi,512);
>> subplot(3,1,1),plot(f/pi,(abs(X1)/max(abs(X1)))),title('DTFT - N=10')
>> subplot(3,1,2),plot(f/pi,(abs(X2)/max(abs(X2)))),title('DTFT - N=20')
>> subplot(3,1,3),plot(f/pi,(abs(X3)/max(abs(X3)))),title('DTFT - N=40')
>> xlabel('X Axis - Frequency in Units of Pi')
DTFT - N=10
1
Each doubling of the
signal length reduces the
main lobe width by half
0.5
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
DTFT - N=20
1
0.5
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0.3
0.4
0.5
0.6
0.7
X Axis - Frequency in Units of Pi
0.8
0.9
1
DTFT - N=40
1
0.5
0
0
0.1
0.2
4
 
N
Effects of Signal Length and Windowing
Gibbs Phenomenon
DTFT - N=10
1
0.5
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0.7
0.8
0.9
1
0.3
0.4
0.5
0.6
0.7
X Axis - Frequency in Units of Pi
0.8
0.9
1
DTFT - N=20
1
0.5
0
0
0.1
0.2
0.3
0.4
0.5
0.6
DTFT - N=40
1
0.5
0
0
0.1
0.2
In all cases, the
rectangular window
(abrupt truncation of
the signal) results in
side lobes (Gibbs
phenomenon)
Effects of Signal Length and Windowing
Tapering Window: The Time Domain
>> x=analog(100,1,100,4000); % 100 Hz sinusoid, 100 ms long, Fs=4kHz
>> xw=x.*hamming(length(x))'; % The Hamming window is given by “hamming”
>> subplot(3,1,1),plot(x),title('Rectangular Windowed Sinusoid, N=401')
>> subplot(3,1,2),plot(hamming(length(x))),title('Hamming Window, N=401')
>> subplot(3,1,3),plot(xw),title('Hamming Windowed Sinusoid, N=401')
>> xlabel('X Axis - Sample Index')
Rectangular Windowed Sinusoid, N=401
1
0
-1
0
50
100
150
200
250
300
350
400
450
350
400
450
350
400
450
Hamming Window, N=401
1
0.5
0
0
50
100
150
200
250
300
Hamming Windowed Sinusoid, N=401
1
0
-1
0
50
100
150
200
250
300
X Axis - Sample Index
The window function
(Hamming) tapers the
abrupt truncation of the
signal but preserves its
frequency characteristics
Effects of Signal Length and Windowing
Tapering Window: The Frequency Domain
>> N=0:39;
>> omega=pi/2;
>> x=cos(omega*N);
>> xw=x.*hamming(length(x))';
>> [X,f]=dtft_demo(x,0,pi,512);
>> [XW,f]=dtft_demo(xw,0,pi,512);
>> subplot(2,1,1),plot(f/pi,abs(X)/max(abs(X)));
>> title('DTFT of Rectangular Windowed Signal, N=40');
>> subplot(2,1,2),plot(f/pi,abs(XW)/max(abs(XW)));
>> title('DTFT of Hamming Windowed Signal, N=40');
>> xlabel('X Axis - Frequency in Units of Pi')
DTFT of Rectangular Windowed Signal, N=40
1
The Hamming window
suppresses the side lobes
but degrades the resolution
of the main lobe
0.8
0.6
0.4
0.2
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
4 r
 
N
r2
DTFT of Hamming Windowed Signal, N=40
1
0.5
0
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
X Axis - Frequency in Units of Pi
0.8
0.9
1
Effects of Signal Length and Windowing
Hamming and Blackman Tapering Windows
>> xb=x.*blackman(length(x))';
>> [XB,f]=dtft_demo(xb,0,pi,512);
>> subplot(2,1,1),plot(f/pi,20*log10(abs(XW)/max(abs(XW))))
>> title('Hamming Window')
>> axis([0,1,-100,0])
>> subplot(2,1,2),plot(f/pi,20*log10(abs(XB)/max(abs(XB))))
>> title('Blackman Window')
Hamming Window
0
1. The Blackman window
suppresses side lobes
further, but…
-50
-100
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
2. The Blackman window
degrades resolution to a
greater extent, r = 2.6
Blackman Window
0
-50
-100
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Effects of Signal Length and Windowing
Comparison of Windows
>> subplot(3,1,1),plot(f/pi,20*log10(abs(X)/max(abs(X))))
>> axis([0,1,-100,0])
>> subplot(3,1,2),plot(f/pi,20*log10(abs(XW)/max(abs(XW))))
>> axis([0,1,-100,0])
>> subplot(3,1,3),plot(f/pi,20*log10(abs(XB)/max(abs(XB))))
0
Rectangular Window
-50
-100
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0
-50
-100
Hamming Window
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
0
Blackman Window
-50
-100
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
Spectral Analysis
Problem: What is the minimum number of samples required
to resolve the spectral components of the signal s(t)?
Assume a sampling frequency of 10 kHz.
s(t )  sin(2 2000t )  .0032sin(2 2500t )  sin(2 3000t)
The spectral components are separated by 500 Hz and the 2500 Hz component is
-50 dB below the other two components. Pick 300 Hz as the desired resolution. A
Blackman window would be required to suppress the side lobes more than 50 dB
 2 f  2
4 r
   


f


N
 fs  fs
or
2rf s
f 
N
N
2rf s (2)(2.6)(10000)

 173
f
300
Spectral Analysis
The Importance of Correct Windowing
>> x=analog([2000 2500 3000],[1 .0032 1],17.3,10000);
>> xh=x.*hamming(length(x))'; % Window the signal with
a Hamming window
>> xb=x.*blackman(length(x))'; % Window the signal
with a Blackman window
>> [Xh,f]=dtft_demof(xh,0,5000,512,10000); % DTFT of
the Hamming signal
>> [Xb,f]=dtft_demof(xb,0,5000,512,10000); % DTFT of
the Blackman signal
>> subplot(2,1,1),plot(f,20*log10(abs(Xh)/max(abs(Xh)))),
axis([0 5000 -80 0])
>> title('DTFT - Hamming Window')
>> subplot(2,1,2),plot(f,20*log10(abs(Xb)/max(abs(Xb)))),
axis([0 5000 -80 0])
>> title('DTFT - Blackman Window')
>> xlabel('Hz')
DTFT - Hamming Window
0
The signal length is 173
-20
-40
-60
-80
0
500
1000
1500
2000
2500
3000
3500
4000
4500
5000
4000
4500
5000
DTFT - Blackman Window
0
-20
-40
-60
-80
0
500
1000
1500
2000
2500
Hz
3000
3500
The Hamming window does not
suppress the side lobes
sufficiently to resolve the weak
component at the correct
relative amplitude (-50 dB)
The Discrete Fourier Transform (DFT)
N 1
X [k ]   x[n]e
 j 2
k
n
N
n 0
k  0,1, 2,...N  1
• The DFT is a discrete transform X[k] of a digital signal rather than a
continuous transform like X(Ω)
• The length of the DFT is equal to the length of the signal
• The DFT is defined always over the interval Ω = [0,2π]
• The DFT turns out to be a sample of the DTFT of x[n] over the
interval [0,2π].
The Discrete Fourier Transform (DFT)
>> n1=0:10;
>> n2=0:40;
>> f=pi/4;
>> y1=cos(f*n1);
>> y2=cos(f*n2);
>> subplot(2,1,1),stem(n1,y1);title('Short Signal,
y1'),xlabel('Sample')
>> subplot(2,1,2),stem(n2,y2);title('Long Signal,
y2'),xlabel('Sample')
>> [X1,omega1]=dft_demo(y1);
>> [X2,omega2]=dft_demo(y2);
>> subplot(2,1,1),stem(omega1/pi,abs(X1));title('DFT of y1')
>> subplot(2,1,2),stem(omega2/pi,abs(X2));title('DFT of y2')
>> xlabel('X axis: Digital Frequency in of pi')
DFT of y1
6
4
Short Signal, y1
1
2
0.5
0
0
-0.5
-1
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
1.2
1.4
1.6
1.8
2
DFT of y2
0
1
2
3
4
5
6
Sample
Long Signal, y2
7
8
9
10
30
1
20
0.5
0
10
-0.5
-1
0
0
5
10
15
20
Sample
25
30
35
40
0
0.2
0.4
0.6
0.8
1
The Discrete Fourier Transform (DFT)
>> [X1_dtft,omega_dtft]=dtft_demo(y1,0,2*pi,512);
>> plot(omega_dtft/pi,abs(X1_dtft))
>> hold
>> stem(omega1/pi,abs(X1), 'k')
>> legend('DTFT of x1','DFT of x1')
>> title('Comparison of DTFT and DFT for Signal x1')
>> hold off
Comparison of DTFT and DFT for Signal x1
6
DTFT of x1
DFT of x1
5
The DFT of a signal
is a sample of the
DTFT in the interval
[0,2π]
4
3
2
1
0
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
Inverse Transforms
x[n] 
1
2

2
X ()e jn d 
Inverse DTFT
where
X ( ) 

 x[n]e
 jn
n 
k
j 2
n
1 N 1
N
x[ n] 
X [ k ]e

N k 0
n  0,1,...N  1
where
N 1
X [ k ]   x[ n]e
n 0
 j 2
k
n
N
Inverse DFT
Energy and Power in Signals
• Analog signals physically transport energy
between two points to do useful work (for
example, from an amplifier to a speaker).
• Digital signals carry information but not physical
energy (digital signals are simply numbers that
represent analog signals).
• We seek something that mathematically
represents energy and power (rate of change of
energy) for digital signals that is computable
from their numerical values.
Power and Energy in Analog Signals
For a sinusoidal voltage with amplitude
A, the power dissipated in the
impedance is
Vrms 2 A2  1 
P

 
R
2 R
That is, the power is proportional to
mean square of the voltage. The
energy consumed is the power X time,
Power and Energy in Digital Signals
• By analogy with an analog signal, we can define the power in a
digital signal to be the mean square of the signal values.
1
P
N
N 1
2
|
x
[
n
]
|

n 0
• Since the number of samples, N, defines a time window (t = NTs),
we can define the energy in a digital signal to be:
N 1
E   | x[n] |2
n 0
Parseval’s Theorem
• Physical signals must obey the conservation of energy. A signal in
the time domain must have the same power as the signal in the
frequency domain.
• Digital signals must also have the same power in the two domains.
Using the inverse DTFT, it can be shown that:
1 N 1
1 N 1
1
2
*
P   | x[n] |   x[n]x [n] 
N n 0
N n 0
2 N

2
|
X
(

)
|
d
 N

• In the above equation, the LHS is the time domain, while the RHS is
the frequency domain. This result is called Parseval’s Theorem
Energy Conservation in Signals
• Parseval’s Theorem states that a digital
signal must have the same power in both
the time (sample) domain and the
frequency domain
• Energy conservation also implies that
digital signal power cannot depend on the
sampling frequency (fs)
Example Power Calculations
• Compute the power in the signal:
s(t )  2sin(2100t )  sin(2 200t )  0.5sin(2 300t )
• The power in the analog signal is
22/2+12/2 +.52/2=2.625
• Compute the power in the digital signal:
– At two different sampling frequencies (1 kHz, 2kHz)
– In the time domain (mean square of the signal values)
– In the frequency domain (integration of the DTFT using the
custom M-file sig_power)
Example Power Calculations
% Construct a pseudo-analog signal and sample at two different Fs:
>> [s,t]=analog([100,200,300],[2,1,.5],1000,50000);
>> d1000=sample(t,s,1000);
>> d2000=sample(t,s,2000);
% Compute the time domain power:
>> [mean(d1000.^2),mean(d2000.^2)]
ans =
2.6224 2.6237 (Total Power does not depend on Fs)
% Compute the frequency domain power:
>> [sig_power(d1000),sig_power(d2000)]
ans =
2.6224 2.6237 (Frequency domain power = time domain power)
Gaussian Noise
• Random electrical noise from the
environment and thermal noise from
components can contaminate analog
voltage signals.
• The noise usually has a “normal” or
“Gaussian” statistical distribution
• In MATLAB, Gaussian noise can be
simulated with the “randn” random number
generator.
Normal Distribution of “randn”
% Create a randn vector with 1000 values:
>> N=1:1000;
>> rn=randn(size(N));
% Compute a histogram of randn values with 11 bins from -3 to 3:
>> xr=-3:6/10:3;
>> M=hist(rn,xr);
% Plot a “normalized”(area = 1) histogram of the randn values:
>> bar(xr,M/(.6*sum(M)))
% Compute the normal pdf of mean 0 and variance 1 from -3 to 3:
>> xn=-3:.01:3;
>> y=pdf('normal',xn,0,1);
% Plot the pdf on the histogram plot:
>> hold
>> plot(xn,y,'r','LineWidth',2)
>> hold off
>> legend('Normalized histogram of randn values','The normal distribution')
Normal Distribution of “randn”
Normalized histogram of randn values
0.45
The normal distribution
0.4
0.35
0.3
0.25
0.2
0.15
0.1
0.05
0
-4
-3
-2
-1
0
1
2
3
4
Noise Signals
>> N1=1:1000;
>> N2=1:2000;
>> t1=N1; % Define each signal to be 1000 milliseconds
long
>> t2=N2/2;
>> n1=randn(size(N1)); % n1 is 1000 samples, 1 ms per
sample
>> n2=randn(size(N2)); % n2 is 2000 samples, 0.5 ms
per sample
>> subplot(2,1,1),plot(t1,n1),title('Gaussian Noise Signal
Sampled at 1 kHz')
>> axis([0 1000 -4 4])
>> subplot(2,1,2),plot(t2,n2),title('Gaussian Noise Signal
Sampled at 2 kHz')
>> axis([0 1000 -4 4])
>> xlabel('X axis - time in milliseconds')
Gaussian Noise Signal Sampled at 1 kHz
4
2
0
-2
-4
0
100
200
300
400
500
600
700
800
900
1000
800
900
1000
Gaussian Noise Signal Sampled at 2 kHz
4
2
0
-2
-4
0
100
200
300
400
500
600
700
X axis - time in milliseconds
The amplitude of the
randn noise signal is,
with high probability,
between -3 and 3
because it has mean zero
and standard deviation 1
Frequency Domain of Gaussian
Noise
>> [X1,f1]=dtft_demof(n1,0,1000,1024,1000);
>> [X2,f2]=dtft_demof(n2,0,2000,1024,2000);
>> subplot(2,1,1),plot(f1,abs(X1)),title('DTFT of n1, Fs = 1 kHz')
>> subplot(2,1,2),plot(f2,abs(X2)),title('DTFT of n2, Fs = 2 kHz')
>> xlabel('X Axis - Frequency in Hz')
DTFT of n1, Fs = 1 kHz
100
50
0
0
100
200
300
400
500
600
700
800
900
1000
800 1000 1200 1400
X Axis - Frequency in Hz
1600
1800
2000
DTFT of n2, Fs = 2 kHz
150
100
50
0
0
200
400
600
For both sampling
frequencies, the noise
power is uniformly
distributed in the
frequency domain
Noise Power Density in the
Frequency Domain
1
P=
2πN
d W=
π
2
|
X
(
W
)
|
dW
ò N
- π
2π
df
fs
f = fs / 2
fs / 2
| X ( f ) |2
P= ò
df
Nf s
- f /2
s
for W= p
fs / 2
ö
æ 1 ÷
öæ
2π
2
çç ÷
÷
P = çç
|
X
(
f
)
|
df
÷
N
ò
÷ççè f ÷
çè 2πN ø
÷
s ø- f / 2
s
| X ( f ) |2
p( f ) =
Nf s
Noise power density is
inversely proportional to
the sampling frequency
Power Density and Sampling
Frequency
>> p1=(abs(X1)).^2/(1000*length(n1)); % The power
density of signal n1
>> p2=(abs(X2)).^2/(2000*length(n2)); % The power
density of signal n2
>> subplot(2,1,1),plot(f1,p1),title('Power Density of n1, Fs
= 1 kHz')
>> axis([0 1000 0 6e-3])
>> subplot(2,1,2),plot(f2,p2),title('Power Density of n2, Fs
= 2 kHz')
>> axis([0 2000 0 6e-3])
-3
x 10
>> xlabel('X Axis - Frequency in Hz')
6
>> mean(p2)
% The average of the power density of
signal n2
>> mean(p1) % The average of the power density of
signal n1
ans =
5.0565e-004
ans =
8.9208e-004
Power Density of n1, Fs = 1 kHz
4
2
0
0
100
200
-3
6
300
400
500
600
700
800
900
1000
1600
1800
2000
Power Density of n2, Fs = 2 kHz
x 10
4
2
0
0
200
400
600
800 1000 1200 1400
X Axis - Frequency in Hz
Frequency Response
The frequency response of a general LTI system can be derived by
taking the DTFT of the difference equation, using the linearity and
time-delay properties.
N
å
M
ak y[n - k ] =
å
k= 0
bk x[n - k ]
k= 0
Y (W) b0 + b1e- jW + b2e- j 2W +
H (W) =
=
X (W) a0 + a1e- jW + a2e- j 2W +
+ bM e- jM W
+ aN e- jNW
M
å
H (W) =
bk e-
jkW
ak e-
jkW
k= 0
N
å
k= 0
H(Ω) is the value of the
transfer function H(z) on the
unit circle z = e jΩ
Filter Shape and Symmetry
>> omega=-pi:2*pi/100:pi; % a vector of 100 values from –pi to pi
>> z=exp(j*omega); % the complex number on the unit circle from –pi to pi
>> H=(.0959-0.1917*z.^-2+0.0959*z.^-4)./(1+0.9539*z.^-2+0.3373*z.^-4);
>> plot(omega/pi,abs(H))
>> title('Example of Filter Shape and Symmetry')
>> xlabel('Digital Frequency in Units of Pi')
>> ylabel('Magnitude of the Filter Frequency Response')
Example of Filter Shape and Symmetry
Magnitude of the Filter Frequency Response
1.4
.0959 - .1917z- 2 + .0959z- 4
H ( z) =
1+ .9539z- 2 + .3373z- 4
1.2
1
0.8
|H(Ω)| is symmetric about
the real axis (Ω = 0)
0.6
0.4
|H (W)| = |H (- W)|
0.2
0
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
Digital Frequency in Units of Pi
0.6
0.8
1
Filter Shape and Symmetry
>> plot(omega/pi,angle(H))
>> title('Filter Phase Angle and Symmetry')
>> xlabel('Digital Frequency in Units of Pi')
>> ylabel('Phase Angle in Radians')
Filter Phase Angle and Symmetry
4
.0959 - .1917z- 2 + .0959z- 4
H ( z) =
1+ .9539z- 2 + .3373z- 4
3
Phase Angle in Radians
2
1
The phase angle is antisymmetric about the real
axis
0
-1
-2
ÐH (W) = - ÐH (- W)
-3
-4
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
Digital Frequency in Units of Pi
0.6
0.8
1
Summary
• The frequency domain of a discrete-time signal is computed from its
discrete-time Fourier transform (DTFT).
• The important properties of the DTFT are its linearity, periodicity,
and its time delay property.
• Use of the DTFT for spectral analysis requires consideration of
signal length (resolution) and window functions (suppression of the
Gibbs phenomenon)
• Conservation of energy (Parseval’s Theorem) requires signal power
to be the same in the time-domain and frequency domain
• Total signal power cannot depend on the sampling frequency
• Signal power density is inversely proportional to the sampling
frequency.
• The frequency response of a linear-time invariant DSP system is the
value of its transfer function on the unit circle in the complex plane,
provided we interpret the angle in the complex plane as the digital
frequency, Ω.