MAKERERE UNIVERSITY
COLLEGE OF ENGINEERING, DESIGN, ART AND TECHNOLOGY
SCHOOL OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND BIOMEDICAL ENGINEERING
COURSE :BSC. ELECTRICAL ENGINNERING
YEAR OF STUDY :YEAR 2 SEMESTER 1
COURSE UNIT : CIRCUIT ANALYSIS 2
COURSE CODE :ELE2122
LECTURER :Dr. JONATHAN SERUGUNDA
DATE OF SUBMITTION: 1/11/2024
work by group 5
group members
no names Registration number course
1 HOFF MEYERS D’KUKS 23/U/08278/PS BELE
2 OKOLONG MICHAEL WALTER 23/U/16701/PS BELE
3 KARABA MOSES ALFRED 23/X/22986/PS BELE
4 KIGANDA JULIUS 23/U/0586 BELE
5 MADOI GEOFREY 23/U/2057 BELE
1
QUESTION 1
1100𝑠𝑠
𝐺𝐺(𝑠𝑠) =
𝑠𝑠 2 + 1100𝑠𝑠 + 10⁵
1100𝑠𝑠
𝐺𝐺(𝑠𝑠) =
(𝑠𝑠 + 1000)(𝑠𝑠 + 100)
11𝑠𝑠
= 𝑠𝑠 𝑠𝑠
1000 �1 + 1000� �1 + 100�
𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡 𝑠𝑠 = 𝑗𝑗𝑗𝑗
11𝑗𝑗ѡ
𝐺𝐺(𝑠𝑠) =
𝑗𝑗ѡ 𝑗𝑗ѡ
1000 �1 + 1000� �1 + 100�
The magnitude will be:
𝑗𝑗ѡ 𝑗𝑗ѡ
20𝑙𝑙𝑙𝑙𝑙𝑙|11| + 20𝑙𝑙𝑙𝑙𝑙𝑙|𝑗𝑗ѡ| − 20𝑙𝑙𝑙𝑙𝑙𝑙|1000| − 20𝑙𝑙𝑙𝑙𝑙𝑙 �1 + � − 20𝑙𝑙𝑙𝑙𝑙𝑙 �1 + �
1000 100
𝑗𝑗ѡ 𝑗𝑗ѡ
The phase will be: ∠ 90 − tan−1 � � − tan−1 � �
1000 100
The bode plot is as follows
2
Using MATLAB to plot the function, the code is shown below:
% Create transfer function
s = tf('s');
H = (1100*s) / (s^2 + 1100*s + 10^5);%transfer function
% Plot Bode plot
figure;
bode(H);
grid on;
title('Bode Plot of the transfer function in question 1')
bode plot :
3
Question 2
Basics of MATLAB
1. Variables: Use ‘=’ to assign values to variables.
2. ‘%’ symbol is used to create single line comments.
3. ‘;’ is used to end a line of code and also in MATLAB it is used to prevent immediate execution
of the code.
Example
R = 100; % resistance in ohms
L = 0.5; % inductance in henries
C = 1e-6; % capacitance in farads
2. Vectors and Matrices: MATLAB uses square brackets to define vectors and matrices.
Example
V = [5, 10, 15]; % a row vector, notice the use of a comma to separate the objects
I = [1; 2; 3]; % a column vector, notice the use of ‘;’ to separate objects
3. Plotting: MATLAB offers powerful plotting features.
Example
t = 0:0.01:1; % time vector from 0 to 1 with 0.01 intervals
y = sin (2 * pi * 10 * t); % a sine wave
plot (t, y); % generic function in matlab that is used for plotting graphs
title ('Sine Wave');
label ('Time (s)');
label('Amplitude');
3. Using Scripts and Functions
Create a script file (.m file) by going to File > New > Script. This file can contain MATLAB code that
you can run all at once.
Application of MATLAB in AC Circuit Analysis
In AC circuit analysis, we often work with phasors and complex impedances to solve circuits in the
frequency domain.
Example: Series RLC Circuit
Consider a series RLC circuit with a resistor R, capacitor C and inductor L
Let's calculate the impedance using Matlab
R = 100; % Resistance in ohms
L = 0.5; % Inductance in henries
C = 1e-6; % Capacitance in farads
4
frequencies = linspace (10, 1000, 1000); % frequency range from 10 Hz to 1000 Hz
Z = zeros(size(frequencies)); % initialize impedance array
for i = 1: length(frequencies)
f = frequencies(i);
Z(i) = R + 1j * (2 * pi * f * L - 1 / (2 * pi * f * C));
end
% Plot the magnitude and phase of impedance
subplot (2, 1, 1);
plot (frequencies, abs(Z));
title ('Magnitude of Impedance');
xlabel ('Frequency (Hz)');
ylabel ('|Z| (Ohms)');
subplot (2, 1, 2);
plot (frequencies, angle(Z) * 180/pi);
title ('Phase of Impedance');
xlabel ('Frequency (Hz)');
ylabel ('Phase (Degrees)');
Exercise
Modify the code to analyze a parallel RLC circuit.
Calculate and plot the current through each component (R, L, C) for an input voltage of 10V (AC) at a
frequency of 500 Hz.
3. Frequency Response Analysis
The frequency response of a circuit shows how the output amplitude and phase shift vary with
frequency. It is essential in filter design.
3.1 Example: Low-Pass RC Filter
Consider a simple RC low-pass filter with input voltage Vin and voltage output across across a
capacitor Vout.
Solution
Let's analyze the frequency response of this RC filter.
R = 1e3; % 1 kOhm resistor
C = 1e-6; % 1 uF capacitor
frequencies = linspace (10, 10000, 10000); % frequency range from 10 Hz to 10 kHz
5
H = zeros(size(frequencies)); % initialize transfer function array
for i = 1: length(frequencies)
f = frequencies(i);
H(i) = 1 / (1 + 1j * 2 * pi * f * R * C);
end
% Plot magnitude and phase of transfer function
subplot (2, 1, 1);
plot (frequencies, abs(H));
title ('Magnitude of Transfer Function');
xlabel ('Frequency (Hz)');
ylabel('|H(f)|');
subplot (2, 1, 2);
plot (frequencies, angle(H) * 180/pi);
title ('Phase of Transfer Function');
xlabel ('Frequency (Hz)');
ylabel ('Phase (Degrees)');
Exercise
Experiment with different values of R and C to see how they affect the filter's cutoff frequency.
Use MATLAB's bode function to plot the Bode plot of this RC filter.
6
QUESTION 3
(a) Design of a simple RC Low-Pass Filter
The transfer function 𝐻𝐻(𝑠𝑠) for an RC low-Pass filter is:
1
𝐻𝐻(𝑠𝑠) =
1 + 𝑠𝑠𝑠𝑠𝑠𝑠
1
𝑓𝑓𝑓𝑓 =
2𝜋𝜋𝜋𝜋𝜋𝜋
𝑓𝑓𝑓𝑓 = 1, 𝑘𝑘𝑘𝑘𝑘𝑘
Taking 𝑅𝑅 = 200 Ω
1
𝐶𝐶 = ≈ 795.77𝑛𝑛𝑛𝑛
2𝜋𝜋 ∙ 1000 ∙ 200
(b) Plot the Bode Plot using MATLAB
% MATLAB code for Bode Plot of an RC low-Pass filter
R = 2e2; % Resistance in ohms
C = 795.77e-9; % Capacitance in Farads
% Define the transfer function H(s) = 1 / (1 + sRC)
num = 1; % Numerator coefficients
den = [R*C, 1]; % Denominator coefficients
sys = tf(num, den); % Create the transfer function midel
% Plot Bode plot
bode(sys);
grid on;
title('Bode Plot of an RC Low-Pass Filter');
7
(c) Effectiveness of the Filter
• Low-Pass filters allow frequencies below the cutoff of (1 kHz) to pass
with minimal attenuation while attenuating higher frequencies.
• For noise suppression, the filter will effectively block high-frequency
noise above the cutoff frequency, ensuring only the desired low-
frequency signals pass through.
• Noise, which often contains high-frequency components, will be
suppressed as its amplitude is reduced.
(d) How the Bode Plot shows High-frequency Attenuation
• In the magnitude plot, the slope decreases at a rate of -20 dB/decade for
frequencies higher than the cutoff frequency. This indicates the filter
attenuates these frequencies.
• The Phase plot will show a phase shift approaching -90° at very high
frequencies, typical for low-Pass filters indicating the delay introduced for
higher frequencies.