07 - 231122 - Advanced - Numerical - Analysis-Fourier Analysis
07 - 231122 - Advanced - Numerical - Analysis-Fourier Analysis
Autumn, 2023
Theory
Periodic functions(1) 2/50
• A periodic function
𝑇𝑇 : period [sec]
𝑓𝑓 = 1/𝑇𝑇 : frequency [Hz]=[1/sec]
• Sinusoids
ℎ(𝑡𝑡) = 𝐴𝐴0 + 𝐶𝐶1 cos( 𝜔𝜔0 𝑡𝑡 + 𝜃𝜃) h(t)
2𝜋𝜋
𝜔𝜔 = 2𝜋𝜋𝜋𝜋 = [rad/sec]
𝑇𝑇
Periodic functions(2) 3/50
• Alternative Representation
ℎ(𝑡𝑡) = 𝐴𝐴0 + 𝐴𝐴1 cos( 𝜔𝜔0 𝑡𝑡) + 𝐵𝐵1 sin( 𝜔𝜔0 𝑡𝑡)
ℎ(𝑡𝑡) = 𝐴𝐴0 + 𝐶𝐶1 cos( 𝜔𝜔0 𝑡𝑡 + 𝜃𝜃)
ℎ(𝑡𝑡) = 𝐴𝐴0 + 𝐴𝐴1 cos( 𝜔𝜔0 𝑡𝑡) + 𝐵𝐵1 sin( 𝜔𝜔0 𝑡𝑡)
where
𝐵𝐵1
𝜃𝜃 = tan−1 −
𝐴𝐴1
Fourier series(1) 4/50
ℎ(𝑡𝑡) = 𝑎𝑎0 + � 𝑎𝑎𝑘𝑘 cos( 𝑘𝑘𝜔𝜔0 𝑡𝑡) + 𝑏𝑏𝑘𝑘 sin( 𝑘𝑘𝜔𝜔0 𝑡𝑡)
𝑘𝑘=1
where
2 𝑇𝑇
𝑎𝑎𝑘𝑘 = � ℎ(𝑡𝑡) cos( 𝑘𝑘𝜔𝜔0 𝑡𝑡)𝑑𝑑𝑑𝑑
𝑇𝑇 0
2 𝑇𝑇
𝑏𝑏𝑘𝑘 = � ℎ(𝑡𝑡) sin( 𝑘𝑘𝜔𝜔0 𝑡𝑡)𝑑𝑑𝑑𝑑
𝑇𝑇 0
Then
∞
where
2 𝑇𝑇/2
𝑐𝑐𝑘𝑘̃ = � ℎ(𝑡𝑡)𝑒𝑒 −𝑖𝑖𝑖𝑖𝜔𝜔0 𝑡𝑡 𝑑𝑑𝑑𝑑 : complex number
𝑇𝑇 −𝑇𝑇/2
Frequency and time domains 6/50
ℎ(𝑡𝑡)
𝜋𝜋
ℎ(𝑡𝑡) = 𝐶𝐶1 cos( 𝑡𝑡 + )
2
ℎ(𝑡𝑡)
Amplitude: 𝐶𝐶1
Angular frequency: 𝜔𝜔0 = 1
• A physical problem
Time domain Frequency domain
(Power spectrum)
Fourier transform
𝐻𝐻(𝑓𝑓)
ℎ(𝑡𝑡)
Inverse Fourier
transform
𝑡𝑡 [sec] 𝑓𝑓 [Hz]
• Fourier transform:
+∞ +∞
𝐻𝐻(𝑓𝑓) = � ℎ(𝑡𝑡)𝑒𝑒 2𝜋𝜋𝜋𝜋𝜋𝜋𝜋𝜋 𝑑𝑑𝑑𝑑 or 𝐻𝐻(𝜔𝜔) = � ℎ(𝑡𝑡)𝑒𝑒 𝑖𝑖𝑖𝑖𝑖𝑖 𝑑𝑑𝑑𝑑
−∞ −∞
• An engineering data
h0 hN-1
t1 t2 tN-1 tN=T
• Sampling theorem
“ℎ(𝑡𝑡) is bandwidth limited to frequencies smaller than 𝑓𝑓𝑐𝑐 ”
(Cannot detect higher frequency than 𝑓𝑓𝑐𝑐 )
DFT: Discrete Fourier Transform(3) 10/50
• To prevent aliasing
1 1
−
2Δ𝑡𝑡 2Δ𝑡𝑡
DFT: Discrete Fourier Transform(4) 11/50
• DFT: +∞
𝐻𝐻(𝑓𝑓𝑛𝑛 ) = � ℎ(𝑡𝑡)𝑒𝑒 2𝜋𝜋𝜋𝜋𝑓𝑓𝑛𝑛 𝑡𝑡 𝑑𝑑𝑑𝑑
−∞
𝑁𝑁−1 𝑁𝑁−1
𝑁𝑁−1
𝑛𝑛
𝐻𝐻𝑛𝑛 ≡ � ℎ𝑘𝑘 𝑒𝑒 2𝜋𝜋𝜋𝜋𝜋𝜋𝜋𝜋/𝑁𝑁 𝑓𝑓𝑛𝑛 ≡
𝑁𝑁
𝑘𝑘=0
𝐻𝐻(𝑓𝑓𝑛𝑛 ) = Δ𝑡𝑡𝐻𝐻𝑛𝑛
• Inverse DFT:
𝑁𝑁−1
1
ℎ𝑘𝑘 = � 𝐻𝐻𝑛𝑛 𝑒𝑒 −2𝜋𝜋𝜋𝜋𝜋𝜋𝜋𝜋/𝑁𝑁
𝑁𝑁
𝑛𝑛=0
FFT: Fast Fourier Transform(1) 12/50
Divided recursively
FFT: Fast Fourier Transform(2) 13/50
• Operation count
Samples (N)
FFT: Fast Fourier Transform(3) 14/50
• Restriction
1. Use N only powers of 2 (N = 2n = … 512, 1024, 2048 …)
2. If N is not power of 2, pad it with zero’s up to the next power of 2
15/50
MATLAB
1 1
• Sampling frequency: 𝑓𝑓𝑠𝑠 = = = 50 Hz
Δ𝑡𝑡 0.02
• Script • Results
(a) f(t) versus time (s)
10
% [1] Data plot
n=8; dt=0.02; fs=1/dt; T = 0.16; 5
tspan=(0:n-1)/fs; 0
y=5+cos(2*pi*12.5*tspan)+sin(2*pi*31.25*tspan); 0 0.02 0.04 0.06 0.08 0.1 0.12 0.14
subplot(3,1,1);
plot(tspan,y,'-ok','linewidth',2,'MarkerFaceColor','black');
(b) Real component versus frequency
title('(a) f(t) versus time (s)');
0.5
% [2] Do the FFT 0
Divide by n in order for that the 1st coefficient is (f = 12.5 Hz)
Y=fft(y)/n; -0.5
Y' equal to the mean of the samples. (not important) 5 10 15 20 25
• Power
2
𝑃𝑃𝑘𝑘 = 𝑐𝑐̃𝑘𝑘
• Example-1
0.25
%f = (1:n/2)/(n/2)*nyquist;
Pyy = abs(Y(1:n/2)).^2; Calculate Power 0.15
figure
stem(f,Pyy,'linewidth',2,'MarkerFaceColor','blue')
0.1
title('Power spectrum')
xlabel('Frequency (Hz)');grid; ylim([0 0.3])
0.05
0
6 8 10 12 14 16 18 20 22 24 26
Frequency (Hz)
Exercise-2 20/50
0.5
10 3
• Hint
0
-1
-1.5
• Script
noise
0.25
% [1] Data plot
n = 64; tn = 2*pi;
dt=tn/n; fs=1/dt; t=(0:n-1)/fs;
0.2
y=cos(10.*t)+sin(3*t)+rand(1,n);
plot(t,y,'-o');grid; pause;
0.15
% [2] Do the FFT & Power
Y=fft(y)/n;
Y(1)=[];YP=Y(1:n/2); 0.1
Pyy = abs(Y).^2;
MS Excel
1) Basic
2) DC component
3) De-trending
4) Window
5) Aliasing
6) Square wave
Usage 22/50
• FFT
N 256 (Excel limit : 4096)
dt
f
0.01 s
100 Hz
Sampling dt
Sampling freq
ℎ(𝑡𝑡) = sin 2𝜋𝜋 2 t + sin 2𝜋𝜋 5 t
df 0.391 Hz df
t_max 3.2 s t_max = dt
Nyquist f 50.0 Hz Critical freq f_c = 1/(2*dt)
• FFT
N 32 (Excel limit : 4096)
dt
f
0.1 s
10 Hz Sampling freq
ℎ(𝑡𝑡) = sin 2𝜋𝜋 1 t
df 0.3125 Hz df
t_max 3.2 s t_max = dt
Nyquist f 5.0 Hz Critical freq f_c = 1/(2*dt)
• Inverse FFT
N 32 (Excel limit : 4096)
dt 0.1 s ℎ(𝑡𝑡) = sin 2𝜋𝜋 1 t
f 10 Hz Sampling freq
df 0.3125 Hz df
t_max 3.2 s t_max = dt
Nyquist f 5.0 Hz Critical freq f_c = 1/(2*dt)
• Removal of DC component
ℎ 𝑡𝑡
ℎ 𝑡𝑡 = sin 2𝜋𝜋𝜋𝜋
De-trending 27/50
• Error occurred
Errors
• Cause of error
• Square wave
• FFT results
∞
4𝐴𝐴0 2𝜋𝜋 2𝑛𝑛 − 1 𝑡𝑡
ℎ(𝑡𝑡) = � 𝑠𝑠𝑠𝑠𝑠𝑠
(2𝑛𝑛 − 1)𝜋𝜋 𝑇𝑇
𝐴𝐴0 = 1, 𝑇𝑇 = 0.25 𝑠𝑠 (𝑓𝑓 = 4 𝐻𝐻𝐻𝐻) 𝑛𝑛=1
33/50
Filtering
1) Convolution theorem
2) Excel example
3) MATLAB example
Convolution 34/50
• Convolution integral
∞
𝑓𝑓 ∗ 𝑔𝑔 𝑡𝑡 = � 𝑓𝑓 𝜏𝜏 𝑔𝑔 𝑡𝑡 − 𝜏𝜏 𝑑𝑑𝜏𝜏
−∞
• Convolution theorem
+∞
Consider 𝐺𝐺 𝑓𝑓 = � 𝑔𝑔 𝑡𝑡 𝑒𝑒 2𝜋𝜋𝜋𝜋𝜋𝜋𝜋𝜋 𝑑𝑑𝑑𝑑 ≡ ℱ{𝑔𝑔} ℱ{}: Fourier transform operator
−∞
+∞
𝐻𝐻(𝑓𝑓) = � ℎ(𝑡𝑡)𝑒𝑒 2𝜋𝜋𝜋𝜋𝜋𝜋𝜋𝜋 𝑑𝑑𝑑𝑑 ≡ ℱ{ℎ}
−∞
Then or
ℱ{𝑔𝑔 ∗ ℎ} = 𝐺𝐺 𝑓𝑓 𝐻𝐻(𝑓𝑓)
∞, 𝑥𝑥 = 0
𝛿𝛿(𝑡𝑡) = �
0, 𝑥𝑥 ≠ 0
∞, 𝑥𝑥 = 𝑇𝑇
𝛿𝛿(𝑡𝑡 − 𝑇𝑇) = �
0, 𝑥𝑥 ≠ 𝑇𝑇
∞
� 𝛿𝛿 𝑡𝑡 𝑑𝑑𝑑𝑑 = 1
−∞
ℱ{𝛿𝛿} = 1
ℱ 𝑔𝑔 ∗ 𝛿𝛿 = ℱ 𝑔𝑔 ℱ 𝛿𝛿 = ℱ 𝑔𝑔
∞
𝑔𝑔 ∗ 𝛿𝛿 𝑡𝑡 = � 𝑔𝑔 𝜏𝜏 𝛿𝛿 𝑡𝑡 − 𝜏𝜏 𝑑𝑑𝜏𝜏
−∞
Excel example : Dirac delta kernel (2) 36/50
Normalized time
Shift 1 Shifted kernel 𝛿𝛿(𝑡𝑡 − 1)
t Kernel h(t) FFT Kernel FFT h(t) Product iFFT t-shift
0 0 0.3 1 15.9666565654047 15.9666565654047 0.3 -1
1 1 0.3 0.98078528040323-0.195090322016128i -5.09158170779648-1.01277857120476i -5.1913316905645-8.88178419700125E-16i 0.3 0
2 0 0.3 0.923879532511287-0.38268343236509i 2.41120380085125+0.998753315958139i 2.60986818735677-4.21884749357559E-15i 0.3 1
3 0 0.3 0.831469612302545-0.555570233019602i -0.387870541381202-0.25916681002911i -0.466487933704626+2.13717932240343E-15i 0.3 2
4 0 0.3 0.707106781186547-0.707106781186548i -0.193982099957017-0.193982099957016i -0.274332116616826+9.15933995315754E-16i 0.3 3
5 0 0.3 0.555570233019602-0.831469612302545i 4.65785003939058E-002+6.9709652105837E-002i 0.0838390857277314+4.57966997657877E-16i 0.3 4
6 0 0.3 0.382683432365089-0.923879532511287i 4.71440392436242E-002+0.113815778927004i 0.123193311380793-1.23512311489549E-15i 0.3 5
7 0 0.3 0.195090322016128-0.98078528040323i -8.00195516800961E-003-4.02285452303434E-002i -0.041016669024442+2.31585584042904E-15i 0.3 6
8 0 0.375311 -1i -6.74391305458326E-002i -0.0674391305458326 0.3 7
9 0 0.486752 -0.195090322016129-0.98078528040323i -4.73892064059265E-003+2.38241628864995E-002i 0.0242909058307897+4.19803081186387E-16i 0.375311099 8
10 0 0.606531 -0.38268343236509-0.923879532511286i -1.62956781019965E-002+3.93412470819081E-002i 0.0425826589912329-7.47665818146004E-16i 0.486752256 9
11 0 0.726149 -0.555570233019603-0.831469612302545i 8.23840043636663E-003-1.23296375682141E-002i -0.0148287290188149+1.07813064031959E-15i 0.60653066 10
12 0 0.83527 -0.707106781186548-0.707106781186547i 2.13999020255143E-002-2.13999020255146E-002i -0.030264031677938+2.32452945780892E-16i 0.726149037 11
13 0 0.923116 -0.831469612302546-0.555570233019601i -6.7686351542714E-003+4.52265741795294E-003i 0.00814056828309937+6.59628601740181E-16i 0.835270211 12
14 0 0.980199 -0.923879532511287-0.382683432365089i -2.2501864171447E-002+9.32057731849245E-003i 0.0243558422712138-1.75207071073658E-15i 0.923116346 13
15 0 1 -0.980785280403231-0.195090322016127i 2.55547285622537E-003-5.08315155610006E-004i -0.00260553752924948+3.69235891861663E-15i 0.980198673 14
16 0 0.980199 -1 2.25860077235236E-002 -0.0225860077235236 1 15
17 0 0.923116 -0.98078528040323+0.195090322016128i 2.5554728562267E-003+5.08315155605787E-004i -0.00260553752924996+7.07984018633034E-16i 0.980198673 16
18 0 0.83527 -0.923879532511287+0.38268343236509i -2.25018641714476E-002-9.32057731849029E-003i 0.0243558422712136-4.96130914129367E-16i 0.923116346 17
19 0 0.726149 -0.831469612302545+0.555570233019602i -6.7686351542709E-003-4.52265741795466E-003i 0.00814056828309991+1.03693095776514E-15i 0.835270211 18
20 0 0.606531 -0.707106781186547+0.707106781186548i 2.13999020255145E-002+2.13999020255143E-002i -0.0302640316779379+1.61329283265843E-16i 0.726149037 19
21 0 0.486752 -0.555570233019602+0.831469612302545i 8.23840043636761E-003+1.23296375682124E-002i -0.014828729018814+6.93022028652734E-16i 0.60653066 20
22 0 0.375311 -0.382683432365089+0.923879532511287i -1.62956781019978E-002-3.93412470819062E-002i 0.0425826589912317-1.23685783837146E-15i 0.486752256 21
23 0 0.3 -0.195090322016128+0.98078528040323i -4.73892064059067E-003-2.38241628865021E-002i 0.0242909058307919+2.00534033822919E-15i 0.375311099 22
24 0 0.3 1i 6.74391305458326E-002i -0.0674391305458326 0.3 23
25 0 0.3 0.195090322016129+0.98078528040323i -8.0019551680063E-003+4.02285452303411E-002i -0.0410166690244391+5.20417042793042E-16i 0.3 24
26 0 0.3 0.38268343236509+0.923879532511286i 4.71440392436218E-002-0.113815778927003i 0.123193311380791-7.56339435525888E-16i 0.3 25
27 0 0.3 0.555570233019603+0.831469612302545i 4.65785003939087E-002-6.97096521058391E-002i 0.0838390857277349+7.21644966006352E-16i 0.3 26
28 0 0.3 0.707106781186548+0.707106781186547i -0.193982099957016+0.193982099957017i -0.274332116616826+9.15933995315754E-16i 0.3 27
29 0 0.3 0.831469612302546+0.555570233019601i -0.387870541381196+0.25916681002911i -0.466487933704621+1.88737914186277E-15i 0.3 28
30 0 0.3 0.923879532511287+0.382683432365089i 2.41120380085124-0.998753315958145i 2.60986818735676-7.66053886991358E-15i 0.3 29
31 0 0.3 0.980785280403231+0.195090322016127i -5.09158170779647+1.01277857120477i -5.19133169056449+1.88737914186277E-14i 0.3 30
Excel example : Gaussian kernel (1) 37/50
1 1 𝑡𝑡 2
−
𝑓𝑓 𝑡𝑡 = 𝑒𝑒 2 𝜎𝜎
𝜎𝜎 2𝜋𝜋
1 1 𝑡𝑡−𝑇𝑇 2
−
𝑓𝑓 𝑡𝑡 − 𝑇𝑇 = 𝑒𝑒 2 𝜎𝜎
𝜎𝜎 2𝜋𝜋
Excel example : Gaussian kernel (2) 38/50
2
Gaussian filter
1 1 𝑡𝑡−𝑡𝑡𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠
sigma 1 −
𝑓𝑓 𝑡𝑡 − 𝑡𝑡𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 = 𝑒𝑒 2 𝜎𝜎
shift 4
Tmax 32 𝜎𝜎 2𝜋𝜋
t Kernel h(t) FFT Kernel FFT h(t) Product iFFT t-shift
0 0.0001 0 0.999998512546039 13 12.9999806630985 0 -4
1 0.0044 1 0.693605265639587-0.693607021787994i 1.90466481291451-9.57539663322764i -5.32047679769587-7.962 1.34E-04 -3
2 0.0540 1 -1.37784952463278E-006-0.925792053866677i -2.63098631369784-1.08979021355164i -1.00891549498454+2.43 4.57E-03 -2
3 0.2420 1 -0.594484557704588-0.594484150818588i 1.21415304466763-1.81710844340743i -1.80203740566927+0.35 5.86E-02 -1
4 0.3989 1 -0.734604268868589-1.05735179245503E-006i -1.70710678118655-1.70710678118655i 1.25404612386174+1.254 0.30052737 0
5 0.2420 1 -0.436710530801492+0.436708465381227i 0.172886800654513-0.115519266975558i -0.0250532446795439+0. 0.69946965 1
6 0.0540 1 -5.64638189074751E-007+0.49959628785912i -0.675576651178546-1.63098631369783i 0.814835089328843-0.337 0.941440375 2
7 0.0044 1 0.274964976931668+0.274963800887644i -0.728789210495159+0.144965187180348i -0.240251687315347-0.16 0.995431341 3
8 0.0001 1 0.291228001750709-1.48671038002757E-006i -1i -1.48671038002757E-06-0 0.99986319 4
9 0.0000 1 0.148407077149866-0.148408237316857i -1.11896985452741-0.222576942790519i -0.19909529727614+0.13 0.99999702 5
10 0.0000 1 5.73230785417534E-007-0.145578767359166i 8.97902135516364E-002-0.216772751324741i -0.0315574584643962-0.0 0.999998506 6
11 0.0000 1 -6.8772002481372E-002-6.87740613251636E-002i -0.938253665384694-0.626921056159531i 0.0214096762416406+0.1 0.999998513 7
12 0.0000 1 -6.27449710312274E-002-1.04520002744413E-006i -0.292893218813453+0.292893218813451i 0.0183778826616934-0.01 0.999998513 8
13 0.0000 1 -2.78767552049874E-002+2.7877168667488E-002i -0.448786179937457-0.671655983099026i 0.0312345696048769+0.0 0.999998513 9
14 0.0000 0 1.36925692745733E-006+2.48020125207467E-002i -0.783227248675261+0.324423348821456i -0.00804742439882835-0 0.999864682 10
15 0.0000 0 1.19371682774361E-002+1.19354280060922E-002i -5.69057478919495E-002-0.286084513706125i 0.0027352476284578-0.00 0.995432834 11
16 0.0000 0 1.43852473644143E-002 -1 -0.0143852473644143 0.941441867 12
17 0.0000 0 1.19371682774363E-002-1.19354280060918E-002i -5.69057478919436E-002+0.286084513706125i 0.00273524762845774+0. 0.699471143 13
18 0.0000 0 1.36925692796135E-006-2.48020125207467E-002i -0.783227248675261-0.324423348821458i -0.00804742439882879+0 0.300528862 14
19 0.0000 0 -2.78767552049871E-002-2.78771686674881E-002i -0.448786179937455+0.671655983099027i 0.0312345696048768-0.00 5.86E-02 15
20 0.0000 0 -6.27449710312271E-002+1.04520002675024E-006i -0.292893218813453-0.292893218813453i 0.0183778826616931+0.0 4.57E-03 16
21 0.0000 0 -6.8772002481372E-002+6.87740613251634E-002i -0.938253665384692+0.626921056159534i 0.0214096762416404-0.10 1.35E-04 17
22 0.0000 0 5.73230785385359E-007+0.145578767359166i 8.97902135516381E-002+0.216772751324737i -0.0315574584643956+0. 1.49E-06 18
23 0.0000 0 0.148407077149866+0.148408237316857i -1.11896985452742+0.222576942790519i -0.199095297276141-0.13 6.09E-09 19
24 0.0000 0 0.291228001750709+1.48671038002757E-006i 1i -1.48671038002757E-06+ 0 20
25 0.0000 0 0.274964976931668-0.274963800887645i -0.72878921049516-0.144965187180343i -0.240251687315346+0.1 0 21
26 0.0000 0 -5.64638189986266E-007-0.49959628785912i -0.67557665117854+1.63098631369783i 0.814835089328844+0.33 0 22
27 0.0000 0 -0.436710530801493-0.436708465381226i 0.17288680065451+0.115519266975554i -0.0250532446795446-0.1 0 23
28 0.0000 0 -0.734604268868589+1.05735179314892E-006i -1.70710678118655+1.70710678118655i 1.25404612386174-1.2540 0 24
29 0.0000 0 𝑡𝑡𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠
-0.594484557704587+0.594484150818589i 1.21415304466764+1.81710844340743i -1.80203740566927-0.358 0 25
30 0.0000 0 -1.37784952252777E-006+0.925792053866677i -2.63098631369783+1.08979021355164i -1.00891549498454-2.435 0 26
31 0.0000 0 0.693605265639589+0.693607021787992i 1.90466481291454+9.57539663322764i -5.32047679769582+7.96 0 27
MATLAB functions 39/50
• Butterworth filtering
[b,a]= butter(n,Wn,ftype)
: designs a lowpass, highpass, bandpass, or bandstop Butterworth filter
y = filter(b,a,x)
: filters the input data x using transfer function coefficients b and a
MATLAB Example: Source code 40/50
clear; clc;
% High-pass filter % band-pass filter
Fs = 200; % Sampling frequency Fs = 200; % Sampling frequency
dt = 1/Fs; dt = 1/Fs;
t = 0:dt:5; t = 0:dt:5;
X = 3*sin(2*pi*3*t)+2*cos(2*pi*40*t); % Example signal X = 3*sin(2*pi*3*t)+1*cos(2*pi*10*t)+2*cos(2*pi*40*t); % Example signal
n = 5; % Order n = 5; % Order
Wn = 10; % Cut-off freq Wn = [8 12]; % 8 - 12 Hz band
Fn = Fs/2; %Nyquist freq Fn = Fs/2; %Nyquist freq
ftype = 'high'; % High-pass ftype = 'bandpass';
[b,a] = butter(n,Wn/Fn,ftype); [b,a] = butter(n,Wn/Fn,ftype);
y = filter(b,a,X); % Filtered signal y = filter(b,a,X); % Filtered signal
subplot(2,1,1); plot(t,X); subplot(2,1,2); plot(t,y); pause; subplot(2,1,1); plot(t,X); subplot(2,1,2); plot(t,y); pause;
5
signal 1500
FFT spectrum
• Original data 1000
500
-5 0
2 1000
• High-pass filter
1 800
0 600
(over 10 Hz) -1
-2
400
200
-3 0
4
1500
• Low-pass filter 2
1000
(below 10 Hz)
0
500
-2
-4
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 10 20 30 40 50 60 70 80 90 100
MATLAB Example: Results (2) 42/50
• Original data 0
1000
500
-5
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0 10 20 30 40 50 60 70 80 90 100
500
400
0.5
• Band-pass filter
300
0
200
(8-12 Hz)
-0.5
100
-1
0
0 10 20 30 40 50 60 70 80 90 100
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
1500
5
• Notch filter
1000
(8-12 Hz)
500
0
-5
0 10 20 30 40 50 60 70 80 90 100
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
43/50
Examples
1) Saw-tooth wave
2) Free to choose
Examples 44/50
1. (Saw-tooth wave) For the saw-tooth wave shown in the figure, solve the followings.
Choose your own 𝑇𝑇 and 𝑁𝑁.
2. (Free to choose) Choose one data in the HW2-3.xlsx, and carry out the FFT.
Examine the effect of de-trending, filtering.
45/50
Appendix
- FFT for sound data (mp3)
Appendix: Example(Music) 46/50
Appendix: Example(Music) 47/50
Frequency spectrum
1 0.014
0.8
0.012
0.6
0.01
Amplitude (arbitrary)
0.4
0.2 0.008
0
0.006
-0.2
-0.4 0.004
-0.6
0.002
-0.8
0
-1
0 2 4 6 8 10 12 0 0.5 1 1.5 2 2.5
5 Frequency (Hz) 4
x 10 x 10
Frequency spectrum
0.8 0.01
0.6
0.008
0.4
Amplitude (arbitrary)
0.2
0.006
0
0.004
-0.2
0.002
-0.4
-0.6 0
0 5 10 15 0 0.5 1 1.5 2 2.5
5
x 10 Frequency (Hz) 4
x 10
Appendix: Human Voice Frequency Range 48/50
Frequency spectrum
0.014
0.012
0.01
Amplitude (arbitrary)
0.008
0.006
0.004
0.002
0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
Frequency spectrum
0.01
0.009
0.008
0.007
Amplitude (arbitrary)
0.006
0.005
0.004
0.003
0.002
0.001
0
0 500 1000 1500 2000 2500 3000 3500 4000
Frequency (Hz)
50/50
Thank you!