% This program computes the nodal voltage U3
% Y is the admittance matrix
% Us is the voltage source phasor
% I is the current matrix 
% U is the voltage vector
Y = [0.05-j*0.0225   j*0.025   -j*0.0025;
     j*0.025     0.01-j*0.0375  j*0.0125;
     -j*0.0025    j*0.0125   0.02-j*0.01];
Us = 8*exp(j*15*pi/180);
I = [0.05*Us; 0; 0];
% solution for nodal voltages
U = inv(Y)*I;
% magnitude of nodal voltage U3
U3_abs = abs(U(3));
% angle of nodal voltage U3 in degrees
U3_ang = angle(U(3))*180/pi;
disp('voltage U3:')
disp(['magnitude = ',num2str(U3_abs),' V'])
disp(['angle = ',num2str(U3_ang),'°'])
