You are on page 1of 2

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%
% Node Voltage Method
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Solve the system of linear equations:
%
(1/120)(51x -3y -8z = 4
%
(1/120)(-3x + 14y -3z) = 0
%
(1/120)(-8x -3y + 41z) = 2
% A=[51/120 -3/120 -8/120; -3/120 14/120 -3/120; -8/120 -3/120 41/120]
% 3x3 Matrix-A
A = [ 51/120 -3/120
-3/120 14/120
-8/120 -3/120

-8/120
-3/120
41/120 ];

% 3x1 Matrix-b
b = [ 4
0
2 ];
% Voltages given by inv(A)*b
V = A\b;
% Prints Voltage values
disp(sprintf('\nVoltages:'));
disp(V);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Mesh Current Method
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Solve the system of linear equations:
%
(58x -40y -15z = 12
%
(-40x + 95y -40z) = 0
%
(-15x -40y + 59z) = -8
% 3x3 Matrix-A
A = [ 58 -40 -15
-40 95 -40
-15 -40 59 ];
% 3x1 Matrix-b
b = [ 12
0
-8 ];
% Current given by inv(A)*b
I = A\b;
% Prints Mesh Current values
disp(sprintf('\nMesh Currents:'));
disp(I);

>> MatLab_Lab3_MatrixInverseMethod

Voltages:
10.9553
4.1246
8.2931

Mesh Currents:
0.3482
0.1775
0.0733

You might also like