傅里葉變換 拉普拉斯變換 Z變換筆記
最近學到工程測試技術,感到大一學的微積分真的和沒學差不多,於是上找博文學習,最後總算弄懂了一點,記錄下來。
首先體驗一個小的實驗
x=linspace(0,30,1000)
y1=8/pi*sin(pi/10*x)
y2=8/3/pi*sin(3*pi/10*x)
y3=8/5/pi*sin(5*pi/10*x)
y=y1
y4=-2*(-1).^(mod(ceil(x/10),2))
for n=3:2:100 n
y=y+8/n/pi*sin(n*pi/10*x)
end
plot(x,y,x,y4)
hold on
plot([0,30],[0,0],'--')
這裏簡單的展示了一下傅里葉級數的效果,下面詳細的介紹一下三個函數
Part1 函數的正交
{1,s i n ( x ) sin(x) s i n ( x ) ,c o s ( x ) cos(x) c o s ( x ) ,·····,s i n ( n x ) sin(nx) s i n ( n x ) ,c o s ( n x ) cos(nx) c o s ( n x ) }
這裏選擇兩個個推導
∫ − π π c o s n x ∗ c o s n x d x \int_{-\pi}^\pi{cosnx*cosnx}\,dx ∫ − π π c o s n x ∗ c o s n x d x
= ∫ − π π 1 + c o s 2 n x 2 d x =\int_{-\pi}^\pi{\frac{1+cos2nx}{2}}\,dx = ∫ − π π 2 1 + c o s 2 n x d x
= π + 1 2 ∫ − π π c o s 2 n x d x =\pi+\frac{1}{2}\int_{-\pi}^\pi{cos2nx}\,dx = π + 2 1 ∫ − π π c o s 2 n x d x
= π =\pi = π
∫ − π π c o s n x ∗ s i n m x d x \int_{-\pi}^\pi{cosnx*sinmx}\,dx ∫ − π π c o s n x ∗ s i n m x d x
= ∫ − π π s i n ( n + m ) x + s i n ( m − n ) x 2 d x =\int_{-\pi}^\pi{\frac{sin(n+m)x+sin(m-n)x}{2}}\,dx = ∫ − π π 2 s i n ( n + m ) x + s i n ( m − n ) x d x
= − 1 2 [ c o s ( n + m ) x m + n + c o s ( m − n ) x m − n ] ∣ − π π =-\frac{1}{2}[\frac{cos(n+m)x}{m+n}+\frac{cos(m-n)x}{m-n}]|_{-\pi}^\pi = − 2 1 [ m + n c o s ( n + m ) x + m − n c o s ( m − n ) x ] ∣ − π π
= 0 =0 = 0
Part2 傅里葉級數推導
通過以上的推導可以知道給出的上述函數座標系是正交的,因此傅里葉級數可以表示爲
f ( x ) = ∑ n = 0 ∞ a n c o s n x + ∑ n = 0 ∞ b n s i n n x = a 0 + ∑ n = 1 ∞ ( a n c o s n x + b n s i n n x ) f(x)=\sum_{n=0}^{\infty}a_ncosnx+\sum_{n=0}^{\infty}b_nsinnx=a_0+\sum_{n=1}^{\infty}(a_ncosnx+b_nsinnx) f ( x ) = ∑ n = 0 ∞ a n c o s n x + ∑ n = 0 ∞ b n s i n n x = a 0 + ∑ n = 1 ∞ ( a n c o s n x + b n s i n n x )
這與通常書本上的會有一些區別
f ( x ) = a 0 + ∑ n = 1 ∞ ( a n c o s n x + b n s i n n x ) f(x)=a_0+\sum_{n=1}^{\infty}(a_ncosnx+b_nsinnx) f ( x ) = a 0 + ∑ n = 1 ∞ ( a n c o s n x + b n s i n n x )
這裏書本上除以2主要是爲了結構上的一致,通過後面的分析就可以知道,這裏先不用管
通過推導可知
a 0 = 1 2 π ∫ − π π f ( x ) d x a_0=\frac{1}{2\pi}\int_{-\pi}^{\pi}f(x)\,dx a 0 = 2 π 1 ∫ − π π f ( x ) d x
a n = 1 π ∫ − π π f ( x ) c o s ( n x ) d x a_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)cos(nx)\,dx a n = π 1 ∫ − π π f ( x ) c o s ( n x ) d x
b n = 1 π ∫ − π π f ( x ) s i n ( n x ) d x b_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)sin(nx)\,dx b n = π 1 ∫ − π π f ( x ) s i n ( n x ) d x
這裏便可以看出課本上將a 0 a_0 a 0 除以的原因了
最終得到傅里葉級數
f ( x ) = a 0 2 + ∑ n = 1 ∞ ( a n c o s n x + b n s i n n x ) f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}(a_ncosnx+b_nsinnx) f ( x ) = 2 a 0 + ∑ n = 1 ∞ ( a n c o s n x + b n s i n n x )
Part3週期爲2L的傅里葉級數的展開
f ( t ) = f ( t + 2 L ) f(t)=f(t+2L) f ( t ) = f ( t + 2 L )
換元
x = π L t ⇒ t = L π x x=\frac{\pi}{L}t\Rightarrow\,t=\frac{L}{\pi}x x = L π t ⇒ t = π L x
則有
f ( t ) = f ( L π x ) ⇒ g ( x ) f(t)=f(\frac{L}{\pi}x)\Rightarrow\,g(x) f ( t ) = f ( π L x ) ⇒ g ( x )
這裏g ( x ) g(x) g ( x ) 的週期爲2 π 2\pi 2 π
通過Part2的推導可知
g ( x ) = a 0 2 + ∑ n = 1 ∞ ( a n c o s n x + b n s i n n x ) g(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty}(a_ncosnx+b_nsinnx) g ( x ) = 2 a 0 + ∑ n = 1 ∞ ( a n c o s n x + b n s i n n x )
a 0 = 1 π ∫ − π π f ( x ) d x a_0=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\,dx a 0 = π 1 ∫ − π π f ( x ) d x
a n = 1 π ∫ − π π f ( x ) c o s ( n x ) d x a_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)cos(nx)\,dx a n = π 1 ∫ − π π f ( x ) c o s ( n x ) d x
b n = 1 π ∫ − π π f ( x ) s i n ( n x ) d x b_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(x)sin(nx)\,dx b n = π 1 ∫ − π π f ( x ) s i n ( n x ) d x
逆向帶回f(t)得到
f ( t ) = a 0 2 + ∑ n = 1 ∞ ( a n c o s n π L t + b n s i n n π L t ) f(t)=\frac{a_0}{2}+\sum_{n=1}^{\infty}(a_ncos\frac{n\pi}{L}t+b_nsin\frac{n\pi}{L}t) f ( t ) = 2 a 0 + ∑ n = 1 ∞ ( a n c o s L n π t + b n s i n L n π t )
a 0 = 1 L ∫ − L L f ( t ) d t a_0=\frac{1}{L}\int_{-L}^{L}f(t)\,dt a 0 = L 1 ∫ − L L f ( t ) d t
a n = 1 L ∫ − L L f ( t ) c o s ( n π L t ) d t a_n=\frac{1}{L}\int_{-L}^{L}f(t)cos(\frac{n\pi}{L}t)\,dt a n = L 1 ∫ − L L f ( t ) c o s ( L n π t ) d t
b n = 1 L ∫ − L L f ( t ) s i n ( n π L t ) d t b_n=\frac{1}{L}\int_{-L}^{L}f(t)sin(\frac{n\pi}{L}t)\,dt b n = L 1 ∫ − L L f ( t ) s i n ( L n π t ) d t
這裏進一步簡化,設函數的週期爲T
則有
f ( t ) = a 0 2 + ∑ n = 1 ∞ ( a n c o s n ω t + b n s i n n ω t ) f(t)=\frac{a_0}{2}+\sum_{n=1}^{\infty}(a_ncosn\omega t+b_nsinn\omega t) f ( t ) = 2 a 0 + ∑ n = 1 ∞ ( a n c o s n ω t + b n s i n n ω t )
a 0 = 2 T ∫ 0 T f ( t ) d t a_0=\frac{2}{T}\int_{0}^{T}f(t)\,dt a 0 = T 2 ∫ 0 T f ( t ) d t
a n = 2 T ∫ 0 T f ( t ) c o s n ω t d t a_n=\frac{2}{T}\int_{0}^{T}f(t)cosn\omega t\,dt a n = T 2 ∫ 0 T f ( t ) c o s n ω t d t
b n = 2 T ∫ 0 T f ( t ) s i n n ω t d t b_n=\frac{2}{T}\int_{0}^{T}f(t)sinn\omega t\,dt b n = T 2 ∫ 0 T f ( t ) s i n n ω t d t
Part4 傅里葉級數&&歐拉公式
傅里葉級數
f ( t ) = a 0 2 + ∑ n = 1 ∞ ( a n c o s n ω t + b n s i n n ω t ) f(t)=\frac{a_0}{2}+\sum_{n=1}^{\infty}(a_ncosn\omega t+b_nsinn\omega t) f ( t ) = 2 a 0 + ∑ n = 1 ∞ ( a n c o s n ω t + b n s i n n ω t )
a 0 = 2 T ∫ 0 T f ( t ) d t a_0=\frac{2}{T}\int_{0}^{T}f(t)\,dt a 0 = T 2 ∫ 0 T f ( t ) d t
a n = 2 T ∫ 0 T f ( t ) c o s n ω t d t a_n=\frac{2}{T}\int_{0}^{T}f(t)cosn\omega t\,dt a n = T 2 ∫ 0 T f ( t ) c o s n ω t d t
b n = 2 T ∫ 0 T f ( t ) s i n n ω t d t b_n=\frac{2}{T}\int_{0}^{T}f(t)sinn\omega t\,dt b n = T 2 ∫ 0 T f ( t ) s i n n ω t d t
歐拉公式
e i θ = c o s θ + i s i n θ e^{i\theta}=cos\theta+isin\theta e i θ = c o s θ + i s i n θ
c o s θ = 1 2 ( e i θ + e − i θ ) cos\theta=\frac{1}{2}(e^{i\theta}+e^{-i\theta}) c o s θ = 2 1 ( e i θ + e − i θ )
s i n θ = − i 2 ( e i θ − e − i θ ) sin\theta=\frac{-i}{2}(e^{i\theta}-e^{-i\theta}) s i n θ = 2 − i ( e i θ − e − i θ )
代入可得
f ( t ) = ∑ − ∞ ∞ c n e i n w t f(t)=\sum_{-\infty}^{\infty}c_ne^{inwt} f ( t ) = ∑ − ∞ ∞ c n e i n w t
c ( n ) = { a 0 2 , n = 0 a n − i b n 2 , n = 1 , 2 , 3 , ⋅ ⋅ ⋅ ⋅ a − n + i b − n 2 , n = − 1 , − 2 , − 3 , ⋅ ⋅ ⋅ ⋅
c(n)=\begin {cases}
\frac{a_0}{2}, & n=0 \\
\frac{a_n-ib_n}{2}, & n=1,2,3,···· \\
\frac{a_{-n}+ib_{-n}}{2},&n=-1,-2,-3,····
\end {cases}
c ( n ) = ⎩ ⎪ ⎨ ⎪ ⎧ 2 a 0 , 2 a n − i b n , 2 a − n + i b − n , n = 0 n = 1 , 2 , 3 , ⋅ ⋅ ⋅ ⋅ n = − 1 , − 2 , − 3 , ⋅ ⋅ ⋅ ⋅
c 0 = a 0 2 = 1 T ∫ 0 T f ( t ) d t c_0=\frac{a_0}{2}=\frac{1}{T}\int_{0}^{T}f(t)dt c 0 = 2 a 0 = T 1 ∫ 0 T f ( t ) d t
c n = 1 T ∫ 0 T f ( t ) e − n w t i d t c_n=\frac{1}{T}\int_{0}^{T}f(t)e^{-nwti}dt c n = T 1 ∫ 0 T f ( t ) e − n w t i d t
c n = 1 T ∫ 0 T f ( t ) e − n w t i d t c_n=\frac{1}{T}\int_{0}^{T}f(t)e^{-nwti}dt c n = T 1 ∫ 0 T f ( t ) e − n w t i d t
因此f ( t ) = f ( t + T ) f(t)=f(t+T) f ( t ) = f ( t + T ) 通過歐拉公式變換的傅里葉級數(傅里葉變換FT)爲
f ( t ) = ∑ − ∞ ∞ c n e − n w t f(t)=\sum\limits_{-\infty}^{\infty}c_ne^{-nwt} f ( t ) = − ∞ ∑ ∞ c n e − n w t
c n = 1 T ∫ 0 T f ( t ) e − n w t i d t c_n=\frac{1}{T}\int_{0}^{T}f(t)e^{-nwti}dt c n = T 1 ∫ 0 T f ( t ) e − n w t i d t
Part5 傅里葉變換(FT)
這裏貼一張圖
我們經常可以聽到傅里葉變換時將時域信號變換到頻域信號
這裏引用上一小節的內容
f T ( t ) = ∑ − ∞ ∞ c n e − n w 0 t f_T(t)=\sum\limits_{-\infty}^{\infty}c_ne^{-nw_0t} f T ( t ) = − ∞ ∑ ∞ c n e − n w 0 t
c n = 1 T ∫ − T 2 T 2 f T ( t ) e − n w 0 t i d t ( w 0 = 2 π T ) c_n=\frac{1}{T}\int_{-\frac{T}{2}}^{\frac{T}{2}}f_T(t)e^{-nw_0ti}dt \qquad(w_0=\frac{2\pi}{T}) c n = T 1 ∫ − 2 T 2 T f T ( t ) e − n w 0 t i d t ( w 0 = T 2 π )
對於非週期函數(T → ∞ T\rightarrow \infty T → ∞ )
lim T → ∞ f T ( t ) → f ( t ) \lim\limits_{T\rightarrow \infty}f_T(t)\rightarrow f(t) T → ∞ lim f T ( t ) → f ( t )
此處頻域之間的間隔Δ ω \Delta\omega Δ ω 隨T的增大而不斷變小,最終T → ∞ T\rightarrow \infty T → ∞ 時Δ w → 0 \Delta w\rightarrow 0 Δ w → 0 ,這就是是與不連續到頻域連續的變換
於是
f T ( t ) = ∑ n = − ∞ ∞ 1 T ∫ − T 2 T 2 f T ( t ) e − i n w 0 t d t e i n w 0 t f_T(t)=\sum\limits_{n=-\infty}^{\infty}\frac{1}{T}\int_{-\frac{T}{2}}^{\frac{T}{2}}f_T(t)e^{-inw_0t}dte^{inw_0t} f T ( t ) = n = − ∞ ∑ ∞ T 1 ∫ − 2 T 2 T f T ( t ) e − i n w 0 t d t e i n w 0 t
f T ( t ) = ∑ n = − ∞ ∞ Δ w 2 π ∫ − T 2 T 2 f T ( t ) e − i n w 0 t d t e i n w 0 t ∗ f_T(t)=\sum\limits_{n=-\infty}^{\infty}\frac{\Delta w}{2\pi}\int_{-\frac{T}{2}}^{\frac{T}{2}}f_T(t)e^{-inw_0t}dte^{inw_0t}\qquad * f T ( t ) = n = − ∞ ∑ ∞ 2 π Δ w ∫ − 2 T 2 T f T ( t ) e − i n w 0 t d t e i n w 0 t ∗
T → ∞ T\rightarrow \infty T → ∞
∫ − t 2 t 2 d t = ∫ − ∞ + ∞ d t \int_{-\frac{t}{2}}^{\frac{t}{2}}dt=\int_{-\infty}^{+\infty}dt ∫ − 2 t 2 t d t = ∫ − ∞ + ∞ d t
∑ n = − ∞ ∞ Δ w → ∫ − ∞ + ∞ d ω \sum\limits_{n=-\infty}^{\infty}\Delta w \rightarrow \int_{-\infty}^{+\infty}d\omega n = − ∞ ∑ ∞ Δ w → ∫ − ∞ + ∞ d ω
將上式代入∗ * ∗ 式得
f ( t ) = 1 2 π ∫ − ∞ + ∞ ∫ − ∞ + ∞ f ( t ) e − i w t d t e i w t d w f(t)=\frac{1}{2\pi}\int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty}f(t)e^{-iwt}dt\,e^{iwt}dw f ( t ) = 2 π 1 ∫ − ∞ + ∞ ∫ − ∞ + ∞ f ( t ) e − i w t d t e i w t d w
這裏截取中間的積分
F ( ω ) = ∫ − ∞ + ∞ f ( t ) e − i w t d t ( 傅 裏 葉 變 換 F T ) F(\omega)=\int_{-\infty}^{+\infty}f(t)e^{-iwt}dt\qquad (傅里葉變換FT) F ( ω ) = ∫ − ∞ + ∞ f ( t ) e − i w t d t ( 傅 裏 葉 變 換 F T )
f ( t ) = 1 2 π ∫ − ∞ + ∞ F ( ω ) e i w t d w ( 傅 裏 葉 變 換 的 逆 變 化 ) f(t)=\frac{1}{2\pi}\int_{-\infty}^{+\infty}F(\omega)e^{iwt}dw\qquad (傅里葉變換的逆變化) f ( t ) = 2 π 1 ∫ − ∞ + ∞ F ( ω ) e i w t d w ( 傅 裏 葉 變 換 的 逆 變 化 )
Part6離散傅裏變換(DFT)
這裏應用前面推導的傅里葉級數
f T ( t ) = ∑ − ∞ ∞ c n e − n w 0 t f_T(t)=\sum\limits_{-\infty}^{\infty}c_ne^{-nw_0t} f T ( t ) = − ∞ ∑ ∞ c n e − n w 0 t
c n = 1 T ∫ − T 2 T 2 f T ( t ) e − n w 0 t i d t = 1 T ∫ 0 T f T ( t ) e − n w 0 t i d t ( w 0 = 2 π T )
c_n=\frac{1}{T}\int_{-\frac{T}{2}}^{\frac{T}{2}}f_T(t)e^{-nw_0ti}dt =\frac{1}{T}\int_{0}^{T}f_T(t)e^{-nw_0ti}dt \qquad(w_0=\frac{2\pi}{T})
c n = T 1 ∫ − 2 T 2 T f T ( t ) e − n w 0 t i d t = T 1 ∫ 0 T f T ( t ) e − n w 0 t i d t ( w 0 = T 2 π )
c n = 1 N ∑ n = 0 N − 1 f ( T N n ) e − i 2 π k n N c_n=\frac{1}{N}\sum\limits_{n=0}^{N-1}f(\frac{T}{N}n)e^{-{i\frac{2\pi kn}{N}}} c n = N 1 n = 0 ∑ N − 1 f ( N T n ) e − i N 2 π k n
這裏w離散,故將其換成了k
這裏進一步簡化爲
c n = 1 N ∑ n = 0 N − 1 Y n W − n k c_n=\frac{1}{N}\sum\limits_{n=0}^{N-1}Y_nW^{-nk} c n = N 1 n = 0 ∑ N − 1 Y n W − n k
W = e 2 π N i W=e^{\frac{2\pi}{N}i} W = e N 2 π i
Y n = f ( n 2 π N ) Y_n=f(n\frac{2\pi}{N}) Y n = f ( n N 2 π )
離散傅里葉逆變換
根據f ( t ) = 1 2 π ∫ − ∞ + ∞ F ( w ) e i w t d w f(t)=\frac{1}{2\pi}\int_{-\infty}^{+\infty}F(w)e^{iwt}dw f ( t ) = 2 π 1 ∫ − ∞ + ∞ F ( w ) e i w t d w 類似推導的
f ( t ) = 1 N ∑ n = 0 N − 1 Y ( n ) e i 2 π k n N f(t)=\frac{1}{N}\sum\limits_{n=0}^{N-1}Y(n)e^{i\frac{2\pi kn}{N}} f ( t ) = N 1 n = 0 ∑ N − 1 Y ( n ) e i N 2 π k n
快速傅里葉變換
是離散傅里葉變換的簡化
如果原來計算DFT的複雜度是NN次運算(N代表輸入採樣點的數量),進行FFT的運算複雜度是N lg10(N)
拉普拉斯變換(Laplace Transform)
傅里葉變換有其固有侷限性:必須滿足迪利克雷條件
在一週期內,連續或只有有限個第一類間斷點;
在一週期內,極大值和極小值的數目應是有限個;
在一週期內,信號是絕對可積的
這裏第三點極大的限制了傅里葉變換的應用範圍
因此laplace變換引入了一個補償因子,使信號衰減e − σ t e^{-\sigma t} e − σ t ,將原本不滿足迪利克雷條件的函數變換爲滿足
∫ − ∞ + ∞ f ( t ) e − σ t e − i w t d t \int_{-\infty}^{+\infty}f(t)e^{-\sigma t}e^{-iwt}\,dt ∫ − ∞ + ∞ f ( t ) e − σ t e − i w t d t
此處令s = σ + w i s=\sigma +wi s = σ + w i
則變形爲∫ − ∞ + ∞ f ( t ) e − s t d t \int_{-\infty}^{+\infty}f(t)e^{-st}dt ∫ − ∞ + ∞ f ( t ) e − s t d t
Z變換
Z變換是基於拉普拉斯變換提出的,不同於拉普拉斯變換的是,Z變換用於分析離散系統,而拉普拉斯變換用於分析連續系統
這裏引入單位衝擊函數
f ( t ) σ T ( t ) = ∑ n = 0 ∞ f ( n T ) σ ( t − n T ) f(t)\sigma_T(t)=\sum_{n=0}^{\infty}f(nT)\sigma(t-nT) f ( t ) σ T ( t ) = ∑ n = 0 ∞ f ( n T ) σ ( t − n T )
s = i w + σ s=iw+\sigma s = i w + σ
F s ( s ) = ∫ 0 ∞ [ ∑ n = 0 ∞ f ( n T ) σ ( t − n T ) ] e − s t d t F_s(s)=\int_{0}^{\infty}[\sum_{n=0}^{\infty}f(nT)\sigma(t-nT)]e^{-st}\,dt F s ( s ) = ∫ 0 ∞ [ ∑ n = 0 ∞ f ( n T ) σ ( t − n T ) ] e − s t d t
= ∑ n = 0 ∞ f ( n t ) e − s n T =\sum_{n=0}^{\infty}f(nt)e^{-snT} = ∑ n = 0 ∞ f ( n t ) e − s n T
令z = e s t z=e^{st} z = e s t
則上式子變爲
= ∑ n = 0 ∞ f ( n t ) z − n =\sum_{n=0}^{\infty}f(nt)z^{-n} = ∑ n = 0 ∞ f ( n t ) z − n
z = e s t = e ( σ + j w ) T = e σ T e j w t = A ( c o s n w t + i s i n ( w t ) ) = A ( a + i b ) z=e^{st}=e^{(\sigma+jw)T}=e^{\sigma T}e^{jwt}=A(cosnwt+isin(wt))=A(a+ib) z = e s t = e ( σ + j w ) T = e σ T e j w t = A ( c o s n w t + i s i n ( w t ) ) = A ( a + i b )
e ( σ + j w ) n T = e σ n T e j w n t = A ( c o s w n t + i s i n w n t ) e^{(\sigma+jw)nT}=e^{\sigma nT}e^{jwnt}=A(coswnt+isinwnt) e ( σ + j w ) n T = e σ n T e j w n t = A ( c o s w n t + i s i n w n t )
當z → z n z\rightarrow z^n z → z n 時相當於打碎了原來的螺旋前進