PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

292 Practical MATLAB® Applications for Engineers


Note that the aforementioned matrix equations can be expressed as [Z] * [I] = [V],
where

Z

j
jj
j



 



()(/)
( (/)) (/)
(/ )

10 20 1 20 20 0
20 20 30 1 40 1 40
0 1 40 10 j(/ )140











and

V





50
0
945













The currents I 1 , I 2 , and I 3 can be evaluated by using the following MATLAB matrix
relation

I = inv (Z) * [V]

MATLAB Solution
% Script file: loops
disp(‘**’)
disp(‘ System Matrices ’)
disp(‘**’)
disp(‘The impedance matrix is given by:’)
Z = [30-j1/20 -20 0;-20 20+j(30-1/40) j(1/40); 0 j(1/40) 10-j(1/40)]
A = 9
exp(j45pi/180);
disp(‘The voltage matrix is given by:’)
V= [5; 0; A]
disp(‘**’)
disp(‘ Loop Currents ’)
disp(‘**’)
% Solve for loop currents I1, I2 and I3
I = inv(Z)V;
% Solve for Magnitude and Phase Angle.
I1mag = abs(I(1));
I2mag = abs(I(2));
I3mag = abs(I(3));
I1ang = angle(I(1))
180/pi;
I2ang = angle(I(2))180/pi;
I3ang = angle(I(3))
180/pi;
% Print currents
disp(‘^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^’)
disp(‘ phasor domain ’)
disp(‘^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^’)
fprintf(‘The magnitude of the Current I1 (in amps) is :%f\n and its
phase angle in degrees is :%f\n’,I1mag,I1ang)
fprintf(‘The magnitude of the current I2 (in amps) is :%f\n and its
phase angle in degrees :%f\n’,I2mag,I2ang)
fprintf(‘The magnitude of the current I3 (in amps)is :%f\n and its
phase angle in degrees is :%f\n’,I3mag,I3ang)
disp(‘^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^’)
disp(‘ time domain ’)
disp(‘^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^’)

Free download pdf