0% found this document useful (0 votes)
79 views22 pages

Part3 - Z-Transform, Filter Analysis, Time-Frequency Analysis

Uploaded by

liyihe2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
79 views22 pages

Part3 - Z-Transform, Filter Analysis, Time-Frequency Analysis

Uploaded by

liyihe2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

🔄

Part3: Time-Frequency Analysis


Created @November 9, 2024 6:16 PM
Person 钱晨灿

Status In progress
Chapter 12: Laplace and z-Transform
12.0 Introduction
12.1 Laplace transform: continuous time, causal system
12.1.1 Laplace transform is a generalized one-sided Fourier transform
12.1.2 Laplace transform turns differential equations into algebraic equations
12.1.3 Transfer function of LTI system: H(s)
12.1.4 Effect of delay on Laplace transform
12.2 z -Transform: equivalent of the Laplace transform in discrete time system
12.3 Three tricks in finding the inverse
12.3.1 Partial fraction expansion
12.3.2 Polynomial division
12.3.3 Divide by z and compensate later
⭐Exercise: how to solve H(z) of a system
⭐Exercise: how to convert H(z) into H(f)
Chapter 16: Filter analysis
16.1 Ideal low pass filter
16.1.1 Characteristic
16.1.2 Mathematical expression
16.1.3 Attributes
16.2 Gibbs phenomenon
Chapter 17: Filter specification, Bode plot, Nyquist plot
17.1 Introduction
17.1.1 Filter specification
17.1.2 Filter characteristic (frequency response)
17.2 Cut-off frequency and -3dB point (half-power point)
17.3 Bode plot, Nyquist diagram
17.3.1 Bode plot
17.3.2 Nyquist plot
Chapter 18: Digital filters and filter design
18.1 Introduction
18.1.1 Linear digital filtering
18.1.2 Zeros and poles of linear digital filters
18.2 Different kinds of filter
18.2.1 IIR, FIR filter
18.2.2 AR, MA, ARMA filter
18.2.3 Causal vs non-causal filters
18.2.4 recognize frequency components in the signals
18.3 Filter characteristics of digital filter
18.3.1 frequency response of digital filters
13.3.2 Review: what does a linear filter do?
13.4 FIR filter design
13.4.1 Window method
13.4.2 classical IIR filters (each optimal in some way)
13.4.3 Implementation
13.4.4 Linear phase filter
Time-frequency analysis
1 Time and frequency resolution
2 Spectral leakage and windowing
3 short-time Fourier transform
4 Wavelets

Chapter 12: Laplace and z-Transform


use the Laplace and z-transforms to analyze the input-output relationship of linear systems

12.0 Introduction
Transforms and solving equations

for some types of problems, the solution in the transformed domain is more easily calculated than
with a direct approach of finding a solution in the time or spatial domain
the idea of using a transformation is to make use of properties that make a problem easier to solve
in the transformed domain
some pair examples for transformation
12.1 Laplace transform: continuous time, causal system
https://www.youtube.com/watch?v=n2y7n6jw5d0

12.1.1 Laplace transform is a generalized one-sided Fourier transform


Laplace transform Fourier transform
+∞ +∞
definition F (s) = ∫0 ​ f (t)e−st dt X(ω) = ∫−∞ x(t)e−jωt dt

复数变量 s = σ + jω jω
时域 [0, +∞],适用于因果系统 [−∞, +∞]
可处理增大、非周期信号 | Laplace transform can 主要适用于能量有限、周期或稳态信号 | Fourier
适用信号
also handle exponential growth | transform can only handle pure sine waves |
contain both exponential growth or decay (σ ),
频域解析度 only contain oscillation (ω ) information
and oscillation (ω ) information
变换结果 得到信号的复频域complex plane (s = σ + jω) 得到信号的频谱(ω)

适用于解线性微分方程,控制系统分析,瞬态与 适用于频率域信号分解和分析,频谱分析和信号
应用
稳态分析 处理
12.1.2 Laplace transform turns differential equations into algebraic equations
Zero initial conditions: often assume the initial condition x(0) = 0 | in time domain |
L[ dx(t)
dt ] =
​ sL[x(t)]
dealing with differentiation is fairly straightforward in the transformed domain

12.1.3 Transfer function of LTI system: H(s)

the function H(s) is the Laplace transform of h(t)


in time domain: y(t) = x(t) ∗ h(t)
in frequency domain: Y (s) = X(s)H(s)
the evaluation of convolution and cross-correlation is replaced by multiplication
also the unit impulse δ(t) response of the LTI system |L[δ(t)] = 1|

12.1.4 Effect of delay on Laplace transform


see also:
12.2 z -Transform: equivalent of the Laplace transform in discrete time
system
the complex variable z can be considered as the delay operator esτ
z −1 = e−sτ

When written in terms of the complex variable z for discrete time series, the Laplace transform
becomes the z -transform
12.3 Three tricks in finding the inverse
12.3.1 Partial fraction expansion
condition: the polynomial order of the numerator is smaller than that of the denominator
1. apply partial fraction expansion to separate the expression into a sum of basic components
2. use a lookup table to find the inverse transform for each basic component

12.3.2 Polynomial division


12.3.3 Divide by z and compensate later

⭐Exercise: how to solve H(z) of a system

⭐Exercise: how to convert H(z) into H(f)


Chapter 16: Filter analysis
16.1 Ideal low pass filter
16.1.1 Characteristic

sharp transition: would completely remove high frequencies while passing low-frequency
components unaltered
no ripples in pass and stop bands
Unfortunately, it cannot be perfectly built in real world, and doesn’t even work well when approximated

16.1.2 Mathematical expression


in frequency domain: H(jω) = {
1, ∣ω∣ ≤ ωc ​

0, ∣ω∣ > ωc
​ ​

sin(ωc t)
in time domain: h(t) = πt

16.1.3 Attributes
1. Non-causal impulse response
output for δ(t) input at t = 0 starts before 0
not possible for physical systems
2. Require infinite memory for digital implementation
infinite length impulse response
infinite steep frequency slope
3. Cause “ringing” effect near edges
convolve an ideal filter with a step causes ripples in its output
applying ideal low pass is like “truncating” Fourier series in the frequency domain |频率上截断|

16.2 Gibbs phenomenon


当用有限项傅里叶级数来逼近一个分段连续但具有跳跃不连续点的函数(非光滑函数)时,在不连续点附
近会出现振荡和过冲(overshoot)。这种现象使得傅里叶级数无法很好地逼近函数的跳跃点。

More coefficients don’t fully solve the problem


Chapter 17: Filter specification, Bode plot, Nyquist plot
17.1 Introduction
17.1.1 Filter specification
Generally, we can obtain the filter/system characteristic by determining the input-output relationship:
1. the system’s reaction to a unit impulse: the unit impulse response h(t)/h(n) | in time domain |
2. the Fourier transform of the unit impulse response h(f )/h(ω) ( frequency response) | in frequency
domain |
3. the Laplace or z-transform of the unit impulse response h(s)/h(z) (transfer function) | in s- or z-
domain |
the unit impulse response is useful because convolution of the unit impulse response with the input
provides the output. The transfer function and frequency response are practical because in the frequency,
s- and z-domain, the convolution may be performed as a multiplication.

17.1.2 Filter characteristic (frequency response)


线性时不变系统起着一种分辨或滤除输入端的各种频率分量的作用。这种滤波性质是由频率响应特性
H(ω)决定的。通常,线性时不变系统会根据它的频率响应来改变输入信号频谱X(ω),产生出频谱为
Y (ω) = H(ω)X(ω)的输出信号。在某种意义上,H(ω)对输入信号中不同频率分量起着加权函数或者
频谱整形函数的作用,因此也可以称为“滤波器”

17.2 Cut-off frequency and -3dB point (half-power point)


Practically, it would be difficult to objectively delimit the precise
bands that define the filter specification. For this reason, the
transition from pass band to the transition band is
conventionally
2
this point corresponds with the frequency where ∣X out (ω)∣
∣Xin (ω)∣2 = ​


1
2

17.3 Bode plot, Nyquist diagram


both of them depict the filter characteristic of a LTI system

17.3.1 Bode plot


contains two plots
in the 1st plot: Amplitude ratio ~ Frequency
power(signalin )
Amplitude ratio = 10log10 power(signal

out )


in the 2nd plot: Phase relationship between output and


input ~ Frequency

17.3.2 Nyquist plot


Bode plot

the Nyquist diagram shows the frequency characteristic as a complex-valued parametric function of
frequency.
the frequency response H(jω) can also be written as a complex-valued
number a + jb
the amplitude ∣H(jω)∣ = a2 + b2 ​

the phase ϕ = arctan( ab ) ​


specific frequency cannot be determined in the plot, but the
arrow indicates the direction in which the frequency
increases (change)
与原点的距离表示Amplitude ratio

与原点连线和Real Axis形成的夹角表示phase

Nyquist diagram

Chapter 18: Digital filters and filter design


18.1 Introduction
18.1.1 Linear digital filtering
Linear digital filtering operation can be expressed as a difference equation
y(n) = b0 x(n) + b1 x(n − 1) + … + bN x(n − N ) − a1 y (n − 1) − a2 y (n − 2) − … −
​ ​ ​ ​ ​

aM y (n − M )

e.g.: 3-point moving average (FIR): y(n) = 13 (xn + xn−1 + xn−2 )


​ ​ ​ ​

e.g.: exponentially weighted moving average (IIR, recursive): y(n) = 13 xn + 23 yn−1


​ ​ ​ ​

we use z -transform to obtain the filter’s transfer function which is determined by two sets of
coefficients: b and a

a0 = 1

linear filters are determined by two set of coefficients b and a, “Filter design” is to find appropriate b
and a
t, h = scipy.signal.dimpulse( system = (b,a,dt) , n )

return the system response to an impulse signal, i.e. h(t)


n: time points
dt: time resolution of the filter
y = scipy.signal.lfilter( b,a,x= signal_in )

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.lfilter.html
filter a data sequence x using a digital filter defined by band a
impulse response: h = signal.lfilter( b , a , r_[1,zeros(N-1)] )

step response: y = signal.lfilter( b,a , r_[0,ones(N-1)] )

18.1.2 Zeros and poles of linear digital filters

zeros: frequencies that are maximally attenuated by the filter


poles: frequencies that are amplified (roughly speaking)

18.2 Different kinds of filter


18.2.1 IIR, FIR filter
FIR IIR
easy to design (b=h) harder to design
always stable could be unstable for some
linear phase not linear phase
more coefficients (higher order) lower order for same steepness

Infinite impulse response (IIR) digital filter


filter output depends on the previous output (for k ≥ 1, ak =
 0 ), which means the response to an

impulse at n = 0 never completely disappears, but continues to influence the system indefinitely
IIR can be potentially unstable (if any pole outside unit circle)
finite impulse response (FIR) digital filter
filter output does’t depend on the previous output: for k ≥ 1, ak = 0

FIR is always stable (no poles)

18.2.2 AR, MA, ARMA filter


Auto-regressive (AR) filters: ∀k, bk = 0 ​

eg.: y(n) = a1 y (n − 1) + a2 y (n − 2)
​ ​

depend on previous output


also IIR
Moving average (MA) filters: ∀k, ak = 0 ​

eg.: y(n) = x(n)+x(n−1)+x(n−2)


B

only depend on input, therefore, FIR


ARMA = AR+MA:
eg.: y(n) = Ay(n − 1) + B0 x(n) + B1 x(n − 1)
​ ​

depend both on previous output and input


IIR

18.2.3 Causal vs non-causal filters


causal filter
you can’t see the future
real-time applications
introduces a delay, depending on filter size
non-causal filter
outputy(n) will be influenced by input after this time point, e.g.,x(n + 1)…
good for offline process, e.g. in computer

18.2.4 recognize frequency components in the signals


bandpass filter: to narrow band signal

lowpass and highpass filter


bandpass

lowpass filter: remove high frequency noise (thick line in plot)


highpass filter: remove low frequency noise (slowly drifting curve in plot)
bandstop filter: narrow band noise (highly regular waves in plot)

18.3 Filter characteristics of digital filter

18.3.1 frequency response of digital filters


substitute z in the transfer function with ejωΔt , Δt is the sample time
z = esτ = ejωΔt
1. compute the frequency response of a digital filter directly: w, H = signal.freqz( b,a , fs = 2*np.pi )

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.freqz.html#scipy.signal.freqz
fs : the sampling frequency of the digital system

ω : the frequencies at which H was computed, in the same units as fs ​

H(ω): corresponding frequency response


2. convert filter representation in time domain to frequency domain: H = scipy.fft.fft( x = h )

conduct Fourier Transform and convert h(n) to H(f )

13.3.2 Review: what does a linear filter do?


in time domain
combing neighboring input (and past output) in a smart way.
convolve with impulse response h(t) to calculate output signal
in frequency domain
spectrum editing
multiplication with the output/input ratio H(ω) to calculate frequency response
frequency domain is much more intuitive

13.4 FIR filter design


you can do it in either time and frequency domain and get the other using FFT
in time domain: finding b or define h
in frequency domain: specify which part of the spectrum to keep or remove
fs : sampling rate

2 : Nyquist frequency
fs
fn = ​

w = 0.4: Normalized frequency where Nyquist frequency correspond to 1. w represents a


proportion that cut frequency/Nyquist frequency
fc = w ∗ fn : cut-off frequency
​ ​

Because the ideal filter cannot be made (Gibbs phenomenon), we always need to
compromise in our approach to the ideal filter characteristic. This compromise
may vary with each application.
in some cases strong attenuation of noise is required, but phase response is
not critical
in other cases, where we want to accurately measure delays, the phase
response is critical.
in the real world, there is a tradeoff between a small transition band and a flat
phase response
13.4.1 Window method
解决在ideal filter中,冲激响应无限长(定义域为无穷)的问题,应用一个窗函数w(n)与hd (n)相乘从 ​

而将冲激响应截断到有限长度。

h(n) = hd (n) × w(n)


different types of windows

Rectangular window: w(n)=1, 对信号直接截断,频率响应中会有明显的Gibbs现象


Hanning window: 边缘平滑,能减少Gibbs现象,但频率分辨率较低
Hamming window: 与Hanning window类似,但是具有更好的频率分辨率和边带衰减
Blackman window: 适合高质量滤波

13.4.2 classical IIR filters (each optimal in some way)


13.4.3 Implementation
FIR design: h(n) = scipy.signal.firwin( numtaps , cutoff , width =None, window =’hamming’, fs =None)

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.firwin.html#scipy.signal.firwin
compute the coefficients of a finite impulse response filter
: length of the filter (number of coefficients). numtaps must be odd if a passband includes
numtaps
the Nyquist frequency
Cutoff : the cutoff frequency of filter OR an array of cutoff frequencies (band edges)
fs : sampling frequency

IIR design: b, a = scipy.signal.butter( N , Wn , btype, fs )

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.butter.html#scipy.signal.butter
Butterworth digital and analog filter design. Design an Nth-order digital or analog Butterworth
filter and return the filter coefficients.
Wn : cut-off frequency
btype : {‘lowpass’, ‘highpass’, ‘bandpass’, ‘bandstop’}, optional

13.4.4 Linear phase filter


shift each freq. component in time by adding an additional phase
“shift” in time domain ↔ “phase change” in frequency domain
each component can be shifted by different amount
change phase of each component in proportion to their frequency: if f1 is shifted by ϕ, the ​

f2 = k ∗ f1 will be shifted by k ∗ ϕ
​ ​

ϕ 1
so than each component will be shifted the same amount in time: Δt = 2π ⋅ f
​ ​

the waveform can get distorted


FIR always has linear phase spectrum, but IIR doesn’t
y = scipy.signal.filtfilt( b,a,x )

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.filtfilt.html#scipy.signal.filtfilt
This function applies a linear digital filter twice, once forward and once backwards. The combined filter
has zero phase and a filter order twice that of the original.

Time-frequency analysis
1 Time and frequency resolution
time resolution: Δt = 1
fs ​

frequency resolution: fres = ​


fs
N

2 Spectral leakage and windowing


A wave at a non-analysis frequency will leak across the entire frequency | FFT后得到的频域是离散的,
频率在这些频率点之间的信号会泄露在整个信号中 |

problem from a wide main-lobe: using a window reduces spectrum leakage, at the expense of a
reduced effective frequency resolution

Hann window has a larger main-lobe width than the rectangular window
problem from high side-lobes: detect a weak signal (50Hz) in the presence of power law noise (strong
low frequency noise)
Hann window shows much better side-lobes attenuation than the rectangular window

3 short-time Fourier transform


Welch’s method for spectrum estimation: frequencies, psd = scipy.signal.welch( signal , fs ,
window =’hanning’, nperseg= , noverlap= )

X = fft(x*window) and stack them together along the time axis

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.welch.html
nperseg : number of each segment, controls frequency and time resolution trade-off

noverlap : number of overlap between 2 segment, usually half og nperseg


Hop size = nperseg - noverlap
use window to reduce spectral leakage

4 Wavelets

You might also like