Young Won Lim9/12/17
Copyright (c) 2009 - 2017 Young W. Lim.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
Please send corrections (or suggestions) to [email protected].
This document was produced by using OpenOffice and Octave.
Digital Signals Octave Codes (0A) 3 Young Won Lim
9/12/17
Based on M.J. Roberts, Fundamentals of Signals and SystemsS.K. Mitra, Digital Signal Processing : a computer-based approach 2nd edS.D. Stearns, Digital Signal Processing with Examples in MATLAB
Digital Signals Octave Codes (0A) 4 Young Won Lim
9/12/17
Sampling and Normalized Frequency
ω0 t = 2π f 0 t
ω0 nT s = 2π f 0nT s
t = nT s
f 0 =1T 0
=2πT 0
nT s
= 2π nT s
T 0
T0 : signal period
Ts : sampling period
F 0 = f 0T s =f 0
f s
= 2π n F0
T s
T 0
=f 0
f s
normalization
normalization
Digital Signals Octave Codes (0A) 5 Young Won Lim
9/12/17
Analog and Digital Frequencies
nω0T s = 2π n f 0T s
ω0 t = 2π f 0 t
Ω0n = 2π n F0
ω0T s = Ω0 f 0T s = F0
Analog Signal
Digital Signal
t = nT st = nT s
Digital Signals Octave Codes (0A) 6 Young Won Lim
9/12/17
Multiplying by Ts – Normalization
ω0 t = 2π f 0 t
Ω0n = 2π n F0
⋅T sNormalization ⋅T s
Analog Signal
Digital Signal
Digital Signals Octave Codes (0A) 7 Young Won Lim
9/12/17
Normalization
F0 = f 0⋅T s
= f 0 / f s
= T s / T 0
Multiplied by Ts
Ω0 = 2πF0
f 0 / f s
f 0⋅T s
Divided by fs
Digital Signals Octave Codes (0A) 8 Young Won Lim
9/12/17
Normalized Cyclic and Radian Frequencies
Normalized Cyclic Frequency
Normalized Radian Frequency
F0 cycles/ sample =f 0 cycles / second
f s samples / second
Ω0 radians /sample =ω0 radians / secondf s samples / second
Digital Signals Octave Codes (0A) 9 Young Won Lim
9/12/17
Periodic Relation
e j(2π(n+N 0)F0) = e j(2πnF0)
2πN 0 F0 = 2πm
N 0 =mF0
Digital Signal Period N0 : the smallest integer
= m⋅T 0
T s
Periodic Condition: integer m
e j2πN 0 F0 = 1
e j2πm = 1
Integer * Rational no: must be an Integer
Digital Signals Octave Codes (0A) 10 Young Won Lim
9/12/17
Periodic Relation
N 0 =mF0
= m⋅T 0
T s
Integer * Rational no: must be an Integer
Integer
Rational numbers
Digital Signals Octave Codes (0A) 11 Young Won Lim
9/12/17
Periodic Relation
e j(2 π(n+N0)F0) = e j (2π n F0)
2π N 0 F0 = 2π⋅m
N 0 =mF0
Digital Signal Period N0 : the smallest integer
= m⋅T 0
T s
Periodic Condition: some integers m
e j (2π f 0)(t+T 0) = e j(2π f 0)t
2π f 0T 0 = 2π⋅m
T 0 =1f 0
Analog Signal Period T0 : the smallest real number
Periodic Condition: for all integer m
Digital Signals Octave Codes (0A) 12 Young Won Lim
9/12/17
Periodic Relation
2π N 0 F0 = 2π⋅m
N 0 =mF0
2π f 0T 0 = 2π⋅m
T 0 =1f 0
Integer N0 Real T
0
Rational F0 Real f
0
=mp /q
= mqp
m = p
N0 = q
m = 1
T 0 =1f 0
Minimum Integer N0 Minimum Real T
0
Digital Signals Octave Codes (0A) 13 Young Won Lim
9/12/17
Periodic Relation
2π N 0 F0 = 2π⋅m
N 0 =mF0
2π f 0T 0 = 2π⋅m
T 0 =1f 0
f 0 =3619
T 0 = 1⋅1936
m = 1
2T 0 = 2⋅1936
m = 2
3T 0 = 3⋅1936
m = 3
F 0 =3619
N 0 = 36⋅1936
m = 36
2N 0 = 72⋅1936
m = 72
3N 0 = 108⋅1936
m = 108
given given
Integer N0 Real T
0
m: multiples of 36 m: all integers
Digital Signals Octave Codes (0A) 14 Young Won Lim
9/12/17
Periodic Condition of a Sampled Signal
Fundamental Frequency
2πF 0n = 2πm
F 0n = m
F 0 =mn
Integers n , m
F 0 =mn
=f 0
f s Sampling Frequency
Rational Number
g(nT s) = A cos(2π f 0T sn+θ)
g [n] = A cos(2π F0 n + θ)
M.J. Roberts, Fundamentals of Signals and Systems
F 0 = f 0T s = f 0/ f s
F 0 =mn
Digital Signals Octave Codes (0A) 15 Young Won Lim
9/12/17
A Cosine Waveform
n= [0:29]; n= [0:29];x= cos(2*pi*(n/10)); x= cos((2/10)*pi*n);
U of Rhode Island, ELE 436, FFT Tutorial
= 2π⋅1⋅n⋅110
f 0 = 1 (T 0 = 1)
T s = 0.1
= 2π⋅110
⋅n⋅1
f 0 = 0.1 (T 0=10)
T s = 1
nT s = n⋅110
nT s = n⋅1
F 0 = f 0T s = 0.1 F 0 = f 0T s = 0.1
2π f 0 nT s2π f 0 nT s
F 0 = f 0T s =f 0
f s
=T s
T 0
Digital Signals Octave Codes (0A) 16 Young Won Lim
9/12/17
Many waveforms share the same sampled data
1.00000 0.80902 0.30902 -0.30902 -0.80902 -1.00000 -0.80902 -0.30902 0.30902 0.80902 1.00000 0.80902 0.30902 -0.30902 -0.80902 -1.00000 -0.80902 -0.30902 0.30902 0.80902 1.00000 0.80902 0.30902 -0.30902 -0.80902 -1.00000 -0.80902 -0.30902 0.30902 0.80902
U of Rhode Island, ELE 436, FFT Tutorial
x
`
3
30
Digital Signals Octave Codes (0A) 17 Young Won Lim
9/12/17
Cosine Wave 1
n= [0:29];x= cos(2*pi*n/10);
U of Rhode Island, ELE 436, FFT Tutorial
ω0 = 2π f 0 =2π
T 0
t = [0:29]/10;y = cos(2*pi*t);stem(t, y)hold ont2 = [0:290]/100;y2 = cos(2*pi*t2);plot(t2, y2)
t = [0:29];y = cos(0.2*pi*t);stem(t, y)hold ont2 = [0:290]/10;y2 = cos(0.2*pi*t2);plot(t2, y2)
ω0 = 2π f 0 =2π
T 0
Digital Signals Octave Codes (0A) 18 Young Won Lim
9/12/17
Normalized Frequency
U of Rhode Island, ELE 436, FFT Tutorial
subplot(2, 1, 1);t = [0:29]/10;y = cos(2*pi*t);stem(t, y)hold ont2 = [0:290]/100;y2 = cos(2*pi*t2);plot(t2, y2)axis([0, 10, -1, 1]);
subplot(2, 1, 2)t = [0:29];y = cos(0.2*pi*t);stem(t, y)hold ont2 = [0:290]/10;y2 = cos(0.2*pi*t2);plot(t2, y2)axis([0, 10, -1, 1]);
f 0 = 1 T 0 = 1
T s = 0.1f s = 10
f 0 = 0.1 T 0 = 10
T s = 1f s = 1
Digital Signals Octave Codes (0A) 19 Young Won Lim
9/12/17
Cosine Wave 1
U of Rhode Island, ELE 436, FFT Tutorial
T 0 = 1
t = [0:29]/10;y = cos(2*pi*t);stem(t, y)hold ont2 = [0:290]/100;y2 = cos(2*pi*t2);plot(t2, y2)
f 0 = 1
T s = 0.1
F0 = f 0T s = 0.1
f 0 = 1 T 0 = 1
T s = 0.1f s = 10
Digital Signals Octave Codes (0A) 20 Young Won Lim
9/12/17
Cosine Wave 2
U of Rhode Island, ELE 436, FFT Tutorial
t = [0:29];y = cos(0.2*pi*t);stem(t, y)hold ont2 = [0:290]/10;y2 = cos(0.2*pi*t2);plot(t2, y2)
f 0 = 0.1
T s = 1
F0 = f 0T s = 0.1
T 0 = 10f 0 = 0.1 T 0 = 10
T s = 1f s = 1
Digital Signals Octave Codes (0A) 21 Young Won Lim
9/12/17
Sampled Sinusoids
M.J. Roberts, Fundamentals of Signals and Systems
g [n] = A eβn
g [n] = A zn z = eβ
g [n] = A cos(2π n /N 0 + θ)
g [n] = A cos(2π F0 n + θ)
m /N 0
g [n] = A cos(Ω0 n + θ)
= F0
= Ω0/2π
2πm /N 0
= 2π F0
= Ω0
N 0 ≠1F0
Digital Signals Octave Codes (0A) 22 Young Won Lim
9/12/17
Sampling Period and Frequency
g [n] = A cos(2π F0 n + θ)
F 0 = f 0T s = f 0/ f s
g (t ) = A cos(2π f 0 t+θ)
g [n] = g(nT s)
g(nT s) = A cos(2π f 0T sn+θ)
g [n] = A cos(2π F0 n + θ)
T s =1f s
sampling period
sampling frequencysampling rate
M.J. Roberts, Fundamentals of Signals and Systems
1T s
= f s
Digital Signals Octave Codes (0A) 23 Young Won Lim
9/12/17
Periodic Condition of a Sampled Signal
Fundamental Frequency
2πF 0n = 2πm
F 0n = m
F 0 =mn
Integers n , m
F 0 =mn
=f 0
f s Sampling Frequency
Rational Number
g(nT s) = A cos(2π f 0T sn+θ)
g [n] = A cos(2π F0 n + θ)
M.J. Roberts, Fundamentals of Signals and Systems
F 0 = f 0T s = f 0/ f s
F 0 =mn
Digital Signals Octave Codes (0A) 24 Young Won Lim
9/12/17
Periodic Condition Examples
g [n] = A cos(2π F0 n + θ)
g (t ) = A cos(2π f 0 t+θ)
g [n] = 4 cos(72πn19 ) = 4cos(2π⋅
3619
⋅n)
g [n] = 4 cos(2π⋅3619
⋅(n + N 0)) N 0 = 19
M.J. Roberts, Fundamentals of Signals and Systems
Fundamental Period of
g (t ) = 4cos(2π⋅3619
⋅(t + T 0)) T 0 =1936
Fundamental Period of
g [n]
g(t )
g [ t ] = 4cos(72π t19 ) = 4cos(2π⋅
3619
⋅t)T s = 1
N 0 ≠1F0
qN 0
= F 0
N 0
q=
1F0
Digital Signals Octave Codes (0A) 25 Young Won Lim
9/12/17
Periodic Condition Examples
g [n] = 4 cos(2π⋅3619
⋅(n + N 0)) N 0 = 19
M.J. Roberts, Fundamentals of Signals and Systems
Fundamental Period of
g (t ) = 4cos(2π⋅3619
⋅(t + T 0)) T 0 =1936
Fundamental Period of
g [n]
g(t )
N 0 ≠1F0
qN 0
= F 0
N 0
q=
1F0
F0 =3619
=qN0 the smallest integer : fundamental period
the number of cycles in N0 samples
Digital Signals Octave Codes (0A) 26 Young Won Lim
9/12/17
Periodic Condition Examples
M.J. Roberts, Fundamentals of Signals and Systems
F0 =3619
=qN0 the smallest integer : fundamental period
the number of cycles in N0 samples
“When F0 is not the reciprocal of an integer (q=1),
a discrete-time sinusoid may not be immediately recognizable from its graph as a sinusoid.”
Digital Signals Octave Codes (0A) 27 Young Won Lim
9/12/17
Periodic Condition Examples
g [n] = 4 cos(2π⋅3619
⋅(n + N 0))
N 0 = 19
M.J. Roberts, Fundamentals of Signals and Systems
Fundamental period of
g (t ) = 4cos(2π⋅3619
⋅(t + T 0))
T 0 =1936
Fundamental period of
g [n]
g(t )
3619
⋅(n + N 0)
3619
⋅(t + T 0)
119
⋅N0 = k
3619
⋅T 0 = k
integer integer
integer integer
N 0
T 0
integer
integer
Digital Signals Octave Codes (0A) 28 Young Won Lim
9/12/17
Periodic Condition Examples
g [n] = 4 cos(2π⋅3619
⋅n)
M.J. Roberts, Fundamentals of Signals and Systems
g [n] = 4 cos(2π⋅119
⋅n)
g [n] = 4 cos(2π⋅219
⋅n)
g [n] = 4 cos(2π⋅319
⋅n)
clf n = [0:36]; t = [0:3600]/100;y1 = 4*cos(2*pi*(1/19)*n);y2 = 4*cos(2*pi*(2/19)*n);y3 = 4*cos(2*pi*(3/19)*n);y4 = 4*cos(2*pi*(36/19)*n);yt1 = 4*cos(2*pi*(1/19)*t);yt2 = 4*cos(2*pi*(2/19)*t);yt3 = 4*cos(2*pi*(3/19)*t);yt4 = 4*cos(2*pi*(36/19)*t);
subplot(4,1,1);stem(n, y1); hold on;plot(t, yt1);subplot(4,1,2);stem(n, y2); hold on;plot(t, yt2);subplot(4,1,3);stem(n, y3); hold on;plot(t, yt3);subplot(4,1,4);stem(n, y4); hold on;plot(t, yt4);
Digital Signals Octave Codes (0A) 29 Young Won Lim
9/12/17
Periodic Condition Examples
N0 = 19
g [n] = 4 cos(2π⋅3619
⋅n)
g [n] = 4 cos(2π⋅119
⋅n)
g [n] = 4 cos(2π⋅219
⋅n)
g [n] = 4 cos(2π⋅319
⋅n)
1 cycle
2 cycles
3 cycles
36 cycles
T s = 1
Digital Signals Octave Codes (0A) 30 Young Won Lim
9/12/17
Periodic Condition Examples
g [n] = A cos(2π F0 n + θ)g (t ) = A cos(2π f 0 t+θ)
M.J. Roberts, Fundamentals of Signals and Systems
g1(t ) = 4cos (2π⋅1⋅t )
g2(t ) = 4cos (2π⋅2⋅t )
g3(t) = 4 cos (2π⋅3⋅t )
t ← nT1
t ← nT 2
t ← nT 3
g1[n] = 4 cos (2πnT s1 )g2[n ] = 4 cos (2πnT s 2 )g3 [n] = 4cos (2π nT s3 )
T 1 =110
T 2 = 120
T 3 = 130
n = 0, 1, 2, 3,⋯
n = 0, 1, 2, 3,⋯
n = 0, 1, 2, 3,⋯
1⋅t = 0, 0.1, 0.2, 0.3,⋯
2⋅t = 0, 0.1, 0.2, 0.3,⋯
3⋅t = 0, 0.1, 0.2, 0.3,⋯
t ← nT1
t ← nT 2
t ← nT 3
{ g1[n] }≡ { g2[n ] }≡ { g2 [n] }
Digital Signals Octave Codes (0A) 31 Young Won Lim
9/12/17
Periodic Condition Examples
g [n] = A cos(2π F0 n + θ)
g (t ) = A cos(2π f 0 t+θ) 2πF 0n = 2πm
g [n] = 4 cos(72 πn19 )
= 4cos(2π(3619 )n)
3619
n = m
3619
=mn
3619
=mn
=f 0
f s
smallest n = 19
1/N0
= F0
= Ω0/2π
= 4cos(2π(3619⋅(n + N 0)))N 0 = 19
M.J. Roberts, Fundamentals of Signals and Systems
smallestF 0 =
qN 0
Digital Signals Octave Codes (0A) 32 Young Won Lim
9/12/17
Periodic Condition Examples
M.J. Roberts, Fundamentals of Signals and Systems
4 cos (ω t1 )
4 cos (2ω t 2)
4 cos (ωn1 )
4 cos (ω2n2 )
t1 = 2 t 2
n1⋅1
n2⋅2
T s = 1
T s = 2
n1 = 2n2
Digital Signals Octave Codes (0A) 33 Young Won Lim
9/12/17
Periodic Condition Examples
M.J. Roberts, Fundamentals of Signals and Systems
clf n = [0:10]; t = [0:1000]/1000;y1 = 4*cos(2*pi*1*n/10);y2 = 4*cos(2*pi*2*n/20);y3 = 4*cos(2*pi*3*n/30);yt1 = 4*cos(2*pi*t);yt2 = 4*cos(2*pi*2*t);yt3 = 4*cos(2*pi*3*t);
subplot(3,1,1);stem(n, y1); hold on;plot(t, yt1);subplot(3,1,2);stem(n/20, y2); hold on;plot(t, yt2);subplot(3,1,3);stem(n/30, y3); hold on;plot(t, yt3);
T s =110
T s =120
T s =130
ω = 2π⋅1
ω = 2π⋅2
ω = 2π⋅3
Digital Signals Octave Codes (0A) 34 Young Won Lim
9/12/17
References
[1] http://en.wikipedia.org/[2] J.H. McClellan, et al., Signal Processing First, Pearson Prentice Hall, 2003[3] M.J. Roberts, Fundamentals of Signals and Systems[4] S.J. Orfanidis, Introduction to Signal Processing[5] K. Shin, et al., Fundamentals of Signal Processing for Sound and Vibration Engineerings
[6] A “graphical interpretation” of the DFT and FFT, by Steve Mann