# Single Phase Voltage Calculation | Matlab

Here, we will find phase voltages VAN, VBN, and VCN, shown in the following figure, using Matlab.

By applying KVL, we come up with the following three equations:

$\begin{matrix} 110\angle {{0}^{o}}=(1+j1){{I}_{1}}+(5+j12){{I}_{1}} & \cdots & (1) \\ 110\angle -{{120}^{o}}=(1-j2){{I}_{2}}+(3+j4){{I}_{2}} & \cdots & (2) \\ 110\angle {{120}^{o}}=(1-j0.5){{I}_{3}}+(5-j12){{I}_{3}} & \cdots & (3) \\\end{matrix}$

After simplifying above equations, we have

$\begin{matrix} 110\angle {{0}^{o}}=(6+j13){{I}_{1}} & \cdots & (4) \\ 110\angle -{{120}^{o}}=(4+j2){{I}_{2}} & \cdots & (5) \\ 110\angle {{120}^{o}}=(6-j12.5){{I}_{3}} & \cdots & (6) \\\end{matrix}$

Let’s put the above three equations in matrix form,

$\left[ \begin{matrix} 6+j13 & 0 & 0 \\ 0 & 4+j2 & 0 \\ 0 & 0 & 6-j12.5 \\\end{matrix} \right]\left[ \begin{matrix} {{I}_{1}} \\ {{I}_{2}} \\ {{I}_{3}} \\\end{matrix} \right]=\left[ \begin{matrix} 110\angle {{0}^{o}} \\ 110\angle -{{120}^{o}} \\ 110\angle {{120}^{o}} \\\end{matrix} \right]$

Now, we can write the above matrix as:

$\left[ Z \right]\left[ I \right]=\left[ V \right]$

From above, we can easily calculate unknown currents using:

$I=inv(Z)*V$

And for the phase voltages:

\begin{matrix} \begin{align} & {{V}_{AN}}=(5+j12){{I}_{1}} \\ & {{V}_{BN}}=(3+j4){{I}_{2}} \\ & {{V}_{CN}}=(5-j12){{I}_{3}} \\\end{align} & \cdots & (7) \\\end{matrix}

Now, it’s time to write Matlab code to find out the phase voltages using the above formulas.

## Measure phase voltages in three-phase system using Matlab


clear all;close all;clc
% Phase Voltages Calculation using Matlab
Z = [6-13*j 0 0;
0 4+2*j 0; % Z-Matrix (Impedance Matrix) from text
0 0 6-12.5*j];
c1=110; %Angle is 0 degree here so we simply ommit it
c2 = 110*exp(j*pi*(-120/180)); % Voltages expressed in phasor form (V=Vm*exp(j*theta))
c3 = 110*exp(j*pi*(120/180)); % Angles are converted into radians (=degrees*pi/180)
V = [c1; c2; c3]; % Voltage Vector [V] mentioned in the text
I = inv(Z)*V; % Calculate unknown Loop currents
%% Phase Voltages Calcualtion
V_an = (5+12*j)*I(1);
V_bn = (3+4*j)*I(2); % Calcualting Phase Voltages using equation (7) in text
V_cn = (5-12*j)*I(3);
% Magnitude and Angle Calculation for each Phase Voltage
V_an_abs = abs(V_an);
V_an_ang = angle(V_an)*180/pi;
V_bn_abs = abs(V_bn);
V_bn_ang = angle(V_bn)*180/pi;
V_cn_abs = abs(V_cn);
V_cn_ang = angle(V_cn)*180/pi;
%% Print out Results
fprintf('Phase Voltage Van \n Magnitude: %f \n Angle in degree: %f \n', V_an_abs, V_an_ang)
fprintf('Phase Voltage Vbn \n Magnitude: %f \n Angle in degree: %f \n', V_bn_abs, V_bn_ang)
fprintf('Phase Voltage Vcn \n Magnitude: %f \n Angle in degree: %f \n', V_cn_abs, V_cn_ang)



Results

Phase Voltage Van

Magnitude: 99.875532

Angle in degree: 132.604994

Phase Voltage Vbn

Magnitude: 122.983739

Angle in degree: -93.434949

Phase Voltage Vcn

Magnitude: 103.134238

Angle in degree: 116.978859