KEMBAR78
GROUP IX Final Simulation | PDF | Electricity | Electrical Engineering
0% found this document useful (0 votes)
13 views23 pages

GROUP IX Final Simulation

The document details a MATLAB simulation conducted by Electrical Group IX, consisting of five members, focusing on various electrical circuit analyses. It includes multiple questions that cover nodal analysis, loop analysis, and power transfer calculations, providing MATLAB scripts and results for each scenario. The results demonstrate the computed voltages, currents, and power dissipation across different configurations and components.

Uploaded by

erickchugu
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)
13 views23 pages

GROUP IX Final Simulation

The document details a MATLAB simulation conducted by Electrical Group IX, consisting of five members, focusing on various electrical circuit analyses. It includes multiple questions that cover nodal analysis, loop analysis, and power transfer calculations, providing MATLAB scripts and results for each scenario. The results demonstrate the computed voltages, currents, and power dissipation across different configurations and components.

Uploaded by

erickchugu
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/ 23

MATLAB SIMULTION

11/28/2024
ELECTRICAL
GROUP IX

Members
1. Feith Maina Wambui J26-2500-2023

2. Nicknashon Ochieng J26-3782-2023

3. Finidy Youngreeen J26-3793-2023

4. Griffin Bukhebi J26-3758-2023

5. Erick Ngua Chugu J26-3739-2023

© 1999 CRC Press LLC


QUESTION ONE

For node V1,

V1 −V2 + V1 −V3 − 5 = 0
10 20
015. V1 − 01. V2 − 005.V3 = 5

At node V2,

V2 −V1 + V2 + V2 −V3 = 0
10 50 40

−01. V1 + 0145.V2 − 0025.V3 = 0

At node V3,

V3 −V1 + V3 −V2 − 2 = 0
20 40

−005.V1 − 0025.V2 + 0075.V3 = 2

Matrix form we have;


MATLAB Script

Y = [ 0.15 -0.1 -0.05;


-0.1 0.145 -0.025;
-0.05 -0.025 0.075];
I = [5;
0;
2];

voltages V1, V2 and V3 are \n') v = inv(Y)*I


diary

MATLAB RESULT:

Nodal voltages V1, V2 and V3,

V=
404.2857
350.0000
412.8571

QUESTION TWO

At node V1
V1 + V1 −V2 + V1 −V4 − 5 = 0
20 5 2

After simplification,

075.V1 − 02. V2 − 05. V4 = 5

At node V2,

V2 −V3 = 10I X

)
I X = (V1 −2V4

Hence:

V2 −V3 = 5(V1 −V4 )

-5V1 +V2 −V3 +5V4 = 0 (4.12)

From super nodes 2 and 3,

V3 + V2 −V1 + V2 + V3 −V4 = 0
10 5 4 15

−02. V1 + 045.V2 + 01667.V3 − 006667.V4 = 0

At nodeV 4,

V4 =10

MATRIX:

MATLAB Script

Y = [0.75 -0.2 0 -0.5;


-5 1 -1 5;
-0.2 0.45 0.166666667 -0.0666666667;
0 0 0 1];
I = [5 0 0 10]';

fprintf('Nodal voltages V1,V2,V3,V4 are \n')


V = inv(Y)*I diary

The Result is

Nodal voltages V1,V2,V3,V4 are

V=
18.1107
17.9153
-22.6384
10.0000

QUESTION THREE
I = I3 − I2 and power supply from the source is P =10I1

For Loop 1,

10(I1 − I2) + 30(I1 − I3) −10 = 0

After simplification,

40I1 −10I2 − 30I3 = 10

For Loop 2,

10(I2 − I1) +15I2 +5(I2 − I3) = 0


After simplification,

−10I1 + 30I2 −5I3 = 0

For Loop 3,

30(I3 − I1) +5(I3 − I2) + 30I3 = 0

− 30I1 −5I2 + 65I3 = 0

Matrix

MATLAB RESULT:

Z = [40 -10 -30;


-10 30 -5;
-30 -5 65];

V = [10 0 0]';

I = inv(Z)*V;

IRB = I(3) - I(2);

fprintf('the current through R is %8.3f Amps \n',IRB)

PS = I(1)*10; fprintf('the power supplied by 10V source is %8.4f


watts \n',PS) diary MATLAB answers are

Current through R = 0.037 A


The power supplied by 10V source = 4.7531W
QUESTION FOUR

MATLAB Script

% maximum power transfer


% vs is the supply voltage
% rs is the supply resistance
% rl is the load resistance
% vl is the voltage across the load
% pl is the power dissipated by the load
vs = 10; rs = 10e3; rl = 0:1e3:50e3; k
= length(rl); % components in vector rl %
Power dissipation calculation for i=1:k
pl(i) = ((vs/(rs+rl(i)))^2)*rl(i); end
% Derivative of power is calculated using backward difference dp
= diff(pl)./diff(rl); rld = rl(2:length(rl)); % length of rld is
1 less than that of rl
% Determination of critical points of derivative of power
prod = dp(1:length(dp) - 1).*dp(2:length(dp)); crit_pt =
rld(find(prod < 0)); max_power = max(pl); %
maximum power is calculated
% print out results

fprintf('Maximum power occurs at %8.2f


Ohms\n',crit_pt) fprintf('Maximum power dissipation is %8.4f
Watts\n', max_power)
% Plot power versus load plot(rl,pl,'+')
title('Power
delivered to load') xlabel('load
resistance in Ohms')
ylabel('power in watts')

The results obtained from MATLAB are

Maximum power occurs at 10000.00 Ohms


Maximum power dissipation is 0.0025 Watts
The plot of the power dissipation obtained from MATLAB is shown in the figure
below

QUESTION FIVE

At node V1,

𝑉 𝑉
+ =3

LCM=4

Hence: 3V1 – 2V3 = 12

At node V2,

𝑉 𝑉
+ =3

LCM=30

6 3

Hence: 11V2 – 6V3 – 5V4 = 90


At node V3;
𝑉 𝑉 𝑉
- - =4

LCM = 30
Hence: 15V2 – 6V2 + V3 – 10V4 = 120
At node V4,

𝑉 𝑉
+ =6
QUESTION SIX
(a)

R C Vo(t)

Assume that for figure (a) C = 10 µF, use MATLAB to plot the voltage across
the capacitor if R is equal to (a) 1.0 kΩ, (b) 10 kΩ and (c) 0.1 kΩ.

Solution

MATLAB Script

% Charging of an RC circuit
%
c = 10e-6; r1
= 1e3; tau1
= c*r1; t =
0:0.002:0.05
; v1 =
10*(1-
exp(t/tau1));
r2 = 10e3;
tau2
= c*r2; v2 =
10*(1-
exp(t/tau2));
r3 = .1e3;
tau3
= c*r3; v3 =
10*(1-exp(t/tau3));
plot(t,v1,'+',t,v2,'o', t,v3,'*')
axis([0 0.06 0 12])
title('Charging of a capacitor with three time
constants') xlabel('Time, s') ylabel('Voltage across
capacitor') text(0.03, 5.0, '+ for R = 1 Kilohms')
text(0.03, 6.0, 'o for R = 10 Kilohms')
text(0.03, 7.0, '* for R = 0.1 Kilohms')

The charging curves.


(B), The input voltage is a rectangular pulse with an amplitude of 5V and a width
of 0.5s. If C = 10 µF, plot the output voltage, v t0 ( ) , for resistance R equal to
(a) 1000 Ω, and (b) 10,000 Ω. The plots should start from zero seconds and
end at 1.5 seconds.

Solution

MATLAB Script

% The problem will be solved using a function program rceval


function [v, t] = rceval(r, c)
% rceval is a function program for calculating
% the output voltage given the values of %
resistance and capacitance.
% usage [v, t] = rceval(r, c)
% r is the resistance value(ohms)
% c is the capacitance value(Farads)
% v is the output voltage
% t is the time corresponding to voltage v
tau = r*c; for i=1:50 t(i) = i/100; v(i) =
5*(1-exp(-t(i)/tau)); end vmax = v(50);

for i = 51:100 t(i) = i/100;


v(i) = vmax*exp(-t(i-50)/tau); end
end

% The problem will be solved using function program


% rceval
% The output is obtained for the various
resistances c = 10.0e-6; r1 = 2500;
[v1,t1] = rceval(r1,c); r2
= 10000; [v2,t2] =
rceval(r2,c);
% plot the voltages
plot(t1,v1,'*w', t2,v2,'+w') axis([0
1 0 6])
title('Response of an RC circuit to pulse
input') xlabel('Time, s') ylabel('Voltage, V') text(0.55,5.5,'*
is for 2500 Ohms')
text(0.55,5.0, '+ is for 10000 Ohms')

Charging and Discharging of a Capacitor with Different


Time Constants

QUESTION SEVEN

Solution

MATLAB Script

diary ex6_1.dat
% This program computes the average power, rms value and
% power factor using quad function. The analytical and %
numerical results are compared.
% numerical calculations

T = 2*pi/(120*pi); % period of the sin wave


a = 0; % lower limit of integration b = T; %
upper limit of integration x = 0:0.02:1; t =
x.*b;
v_int = quad('voltage1', a, b); v_rms =
sqrt(v_int/b); % rms of voltage i_int =
quad('current1',a,b); i_rms =
sqrt(i_int/b); % rms of current

p_int = quad('inst_pr', a, b); p_ave =


p_int/b; % average power
pf = p_ave/(i_rms*v_rms); % power factor
%
% analytical solution
% p_ave_an = (60/2)*cos(30*pi/180); % average power
v_rms_an
= 10.0/sqrt(2); pf_an =
cos(30*pi/180);

% results are printed fprintf('Average power, analytical %f \n Average


power, numerical: %f \n', p_ave_an,p_ave)
fprintf('rms voltage, analytical: %f \n rms voltage, numerical: %f \n',
v_rms_an, v_rms)
fprintf('power factor, analytical: %f \n power factor, numerical: %f \n',
pf_an, pf)
diary

The following functions are used in the above m-file:

function vsq = voltage1(t) % voltage1


This function is used to % define
the voltage function vsq =
(10*cos(120*pi*t + 60*pi/180)).^2; end

function isq = current1(t)


% current1 This function is to define the current
%
isq = (6*cos(120*pi*t + 30.0*pi/180)).^2; end

function pt = inst_pr(t)
% inst_pr This function is used to define
% instantaneous power obtained by multiplying
% sinusoidal voltage and current
it = 6*cos(120*pi*t + 30.0*pi/180); vt
= 10*cos(120*pi*t + 60*pi/180); pt =
it.*vt; end

The results obtained are

Average power, analytical 25.980762


Average power, numerical:
25.980762 rms voltage, analytical:
7.071068 rms voltage, numerical:
7.071076 power factor, analytical:
0.866025 power factor, numerical:
0.866023

From the results, it can be seen that the two techniques give almost the same
answers.

QUESTION EIGHT
Using nodal analysis, we obtain the following equations.

At node 1,

At node 2,

At node 3,

Substituting the element values in the above three equations and simplifying, we
get the matrix equation
[Y] [V] = [I] .
We can compute the vector [v] using the MATLAB command

V = inv (Y) * I

where inv (Y) is the inverse of the matrix [Y]

A MATLAB program for solving V3 is as follows:

MATLAB Script

diary ex6_2.dat
% This program computes the nodal voltage v3 of circuit
% Y is the admittance matrix; % I is the current matrix
% V is the voltage vector

Y = [0.05-0.0225*j 0.025*j -0.0025*j; 0.025*j


0.01-0.0375*j 0.0125*j;
-0.0025*j 0.0125*j 0.02-0.01*j];

c1 = 0.4*exp(pi*15*j/180);
I = [c1
0
0]; % current vector entered as column vector

V = inv(Y)*I; % solve for nodal voltages v3_abs


= abs(V(3)); v3_ang =
angle(V(3))*180/pi;

fprintf('voltage V3, magnitude: %f \n voltage V3, angle in degree:


%f', v3_abs, v3_ang) diary

Results are:

voltage V3, magnitude: 1.850409 voltage


V3, angle in degree: -72.453299

From the MATLAB results, the time domain voltage v t3( ) is

v t3( ) = 185.cos(10t − 72 45.0 ) V

QUESTION NINE
Using loop analysis, we have

− 5∠00 + (4 − j2 5. )I1 + (6 + j5 − j10)(I1 − I2 ) = 0 (6.24)

(10 + j8)I2 + 2∠750 + (6 + j5 − j10)(I2 − I1) = 0 (6.25)

Simplifying, we have

(10 − j7.5)I1 − (6 − j5)I2 = 5∠00

− (6 − j5)I1 + (16 + j3)I2 = −2∠750

In matrix form, we obtain

The above matrix equation can be rewritten as

[Z][I] = [V] .

We obtain the current vector [ ]I using the MATLAB command

I = inv (Z) *V

where inv (Z ) is the inverse of the matrix [Z] .

The voltage VC can be obtained as


VC = −( j10)(I1 − I2 )

A MATLAB program for determining I1 and Va is as follows:

MATLAB Script

diary ex6_3.dat
% This programs calculates the phasor current I1 and %
phasor voltage Va.
% Z is impedance matrix
% V is voltage vector
% I is current vector

Z = [10-7.5*j -6+5*j;
-6+5*j 16+3*j];

b = -2*exp(j*pi*75/180); V = [5
b]; % voltage vector in column form I =
inv(Z)*V; % solve for loop currents i1 =
I(1); i2 = I(2);

Vc = -10*j*(i1 - i2); i1_abs


= abs(I(1)); i1_ang =
angle(I(1))*180/pi; Vc_abs
= abs(Vc);
Vc_ang = angle(Vc)*180/pi;

%results are printed


fprintf('phasor current i1, magnitude: %f \n phasor current i1, angle in
degree: %f \n', i1_abs,i1_ang)
fprintf('phasor voltage Vc, magnitude: %f \n phasor voltage Vc, angle
in degree: %f \n',Vc_abs,Vc_ang) diary

Results are:

phasor current i1, magnitude: 0.387710 phasor


current i1, angle in degree: 15.019255 phasor
voltage Vc, magnitude: 4.218263 phasor
voltage Vc, angle in degree: -40.861691

The current i (t1) is

i (t1) = 0 388.cos(103t + 1502.0 ) A

and the voltage vC (t) is

vC (t)= 4 21.cos(103t − 40 86.0 ) V

QUSTION TEN
PSPICE SIMULATION

QUESTION ONE
QUESTION TWO

You might also like