Lab 1: Passive Filters, Linear Regression and Fourier Series
Requirement for Lab report
1.Derivation in writing, or typed up in L ATEX or MS Word 2.MATLAB/Octave code or script with proper comments 3.Graph resulting from the MATLAB/Octave code or script 4.Brevity will be rewarded
(Q1). Passive First Order Filter: The response of an AC signal to capacitance and induc- tance is frequency dependent with 90o phase gap. However, when combined with a resistor, both the magnitude and phase responses are dependent on frequency. For the below given circuit
VL
|
+ L +
+
Vs R VR
− −
dimensional terms i.e. and ω ωc?
ω
instead of
ωc
ωL
R . What is the response for ω ωc
|
circuit. The inputs of the function are the values of capacitance L in Henry, resistance R in Ohms and range of frequencies (vector of frequencies from f1 to f2 frange = f1 : (step) : f2).
Hint:
Input format – plotRLResponse(freqRange, R, L) where
freqRange = range of frequency. Units – Hertz(Hz) : 1 × N row vector
R = resistance value expressed in Ohms (Ω): 1 × 1 scalar
L = inductance value expressed in Henry(H) : 1 × 1 scalar
(Q2). Butterworth Filter: First order filters do not generate flat frequency response. To obtain flatter responses, higher order filters are used. For the below given filter
L1 L3
L1, C2, L3, R4.
Vout (iω) R4
=
(2.1)
Vs (iω) (iω)3(L1C2L3) + (iω)2(L1C2R4) + (iω)(L1 + L3) + R4
The denominator is third order polynomial in ω, hence, the filter is 3rd order. What is the response of the filter at ω → 0 and ω → ∞?
Vout Vs
1
= √1 + ω6 (2.2)
Plot this response in MATLAB/Octave and compare it with equivalent first
order normalized response (Q1 for ωc = 1) of
Vout Vs
1
= √1 + ω2 . For nth order
filter the response is
Vout
Vs
1
= √1 + ω2n . Compare previous responses with
that of higher order filters – n = 4, 5.
(Q3). Wheatstone Bridge: Bridge circuits are a common way to measure component val- ues by comparing them to known values. Often an unknown element is put in one arm and then the bridge is nulled by adjusting the other arm or varying the frequency. Wheatstone bridge comprises of four resistors and is used to measure unknown electrical resistance. A wheatstone bridge has ability to provide extremely accurate measurements unlike a voltage divider.
Vs Q
(Q4). Linear Least Squares: Linear regression can be viewed as minimization of least squares error. For a linear relationship between dependent variable y and indepen- dent variable x, m, c denote the linear unknowns.
y = mx + c (4.1)
|
For N data points (xi, yi) i [1, N ] The error ei between the measured quantity and the model predicted value is
ei = (mxi + c − yi) (4.2)
2 3 2
e1
3 2 3
x1 1 y1
6 e2 7
6 x2 1 7
e = Az − b, where e = 6
7 A = 6
7 b = 6
6 7 6 7 6 7
|
|
4 5 4 . . 5 4 5 b
eN xN 1 yN
|
Prove that the solution to min 1||e||2 is
z∗ = A†b
(4.3)
where the pseudoinverse A† = (AT A)−1AT . This is commonly referred to as the linear least squares method.
y = a1x + a2 (4.4)
Using linear least squares method, write MATLAB/Octave code to find a1, a2
y
|
4
3
2
1
0 x
0 1 2 3 4
y = a1x + a2ex + a3
Find a1, a2, a3 by linear least squares method. Write the code in MALTAB/Octave.
y
|
16
12
8
4
0 x
1 2 3 4 5
(Q5). Fourier Series: Fourier series allows representation of complicated signals as super- position (linear combination) of sine and cosine waves utilizing the orthogonality between the trigonometric functions. Any signal can be represented as a sum of N sinusoidal terms
|
S (t) =
a0 + X
a cos
2πn
t + b
sin
2πn
t (5.1)
i.e., for n, m ∈ I
N
Z T /2
2 n T
n=1
2π 2π
n T
0 ,m ƒ= n
−T /2
Z T /2
−T /2
Z T /2
cos
sin
nt cos
T
2π
nt sin
T
2π
mt dt =
T
2π
mt dt =
T
2π
T ,m = n
|
|
0 ,m ƒ= n
2
−T /2
cos
nt sin
T
T mt dt = 0, ∀m, n
Z T /2
−T /2
cos
2π
nt dt =
T
Z
Z T /2
−T /2
sin
2π
nt dt = 0
T
2
an = T
T /2
−T /2
SN (t) cos
2πn
t dt (5.2)
T
2 Z T /2
bn = T
−T /2
SN (t) sin
2πn
t dt (5.3)
T
Ssquare
(t) = +1, t ∈ [−T /2, 0]
−1, t ∈ (0, +T /2]
(5.4)
show that the Fourier Series representation is
SN =
XN
n=1
4
sin
(2n − 1)π
2π
T (2n − 1)t (5.5)
Write a MATLAB function squareFourierWave(N) that plots the sum of the N terms of the obtained Fourier Series. Observe the plots as N increases from 2, 4, 8, · · · , 1024 and compare with the original piecewise continuous function.
Ssawtooth(t) =
2t
(5.6)
T
Write a MATLAB function sawtoothFourierWave(N) that plots the sum the first N terms of the series.