0% found this document useful (0 votes)
120 views

Phasor Toolbox For AC Circuit Analysis Using MATLAB

This document describes a MATLAB phasor toolbox for analyzing AC circuits. [1] The toolbox contains functions for converting between complex, polar, and phasor representations and for performing mathematical operations on phasors like addition, subtraction, multiplication, and division. [2] It also includes functions for plotting phasors on the complex plane and in the time domain, analyzing series-parallel networks, and calculating equivalent circuits and power. [3] The toolbox is designed to help teach fundamental circuit analysis concepts in a way that reduces errors and enhances visualization compared to traditional calculator-based methods.

Uploaded by

Ctstrphy
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)
120 views

Phasor Toolbox For AC Circuit Analysis Using MATLAB

This document describes a MATLAB phasor toolbox for analyzing AC circuits. [1] The toolbox contains functions for converting between complex, polar, and phasor representations and for performing mathematical operations on phasors like addition, subtraction, multiplication, and division. [2] It also includes functions for plotting phasors on the complex plane and in the time domain, analyzing series-parallel networks, and calculating equivalent circuits and power. [3] The toolbox is designed to help teach fundamental circuit analysis concepts in a way that reduces errors and enhances visualization compared to traditional calculator-based methods.

Uploaded by

Ctstrphy
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/ 10

Paper ID #23506

Phasor Toolbox for AC Circuit Analysis Using MATLAB


Dr. Jai P. Agrawal, Purdue University Northwest
Jai P. Agrawal is a professor in electrical and computer engineering technology at Purdue University,
Calumet. He received his Ph.D. in electrical engineering from University of Illinois, Chicago, in 1991,
dissertation in power electronics. He also received M.S. and B.S. degrees in electrical engineering from
Indian Institute of Technology, Kanpur, India, in 1970 and 1968, respectively. His expertise includes
analog and digital electronics design, power electronics, nanophotonics, and optical/wireless networking
systems. He has designed several models of high frequency oscilloscopes and other electronic test and
measuring instruments as an entrepreneur. He has delivered invited short courses in Penang, Malaysia and
Singapore. He is also the author of a textbook in power electronics, published by Prentice-Hall, Inc. His
professional career is equally divided in academia and industry. He has authored several research papers
in IEEE journals and conferences. His current research is focused on renewable energy technology, smart
energy grid.
Prof. Omer Farook, Purdue University Northwest

Omer Farook is a member of the faculty of Electrical and Computer Engineering Technology at Purdue
University, Nothwest. Farook received the diploma of licentiate in mechanical engineering and B.S.M.E.
in 1970 and 1972, respectively. He further received B.S.E.E. and M.S.E.E. in 1978 and 1983, respec-
tively, from Illinois Institute of Technology. Farook’s current interests are in the areas of embedded
system design, hardware-software interfacing, digital communication, networking, image processing, and
biometrics, C++, Python, PHP and Java languages. He has a keen interest in pedagogy and instruction de-
livery methods related to distance learning. He has a deep commitment to social justice and in achieving
economic and educational equity.
Dr. Wangling Yu, Purdue University Northwest
Dr. Wangling Yu is an assistant professor in the Electrical & Computer Engineering Technology De-
partment of the Purdue University Northwest. He was a test engineer over 15 years, providing technical
leadership in the certification, testing and evaluation of custom integrated security systems. He received
his PhD degree in Electrical Engineering from the City University of New York in 1992, specializing in
control theory and electronic technology.

American
c Society for Engineering Education, 2018
PHASOR TOOLBOX FOR AC CIRCUIT ANALYSIS USING MATLAB

Abstract

MATLAB is a very useful tool which can be utilized in teaching DC and AC Circuits courses.
Introduction of MATLAB in the Engineering Technology program empowers the students in the
early stage of their learning process. This paper presents a MATLAB phasor toolbox for analyz-
ing ac sinusoidal circuits in the Electrical and Computer Engineering Technology program. The
toolbox has functions for conversion among complex, polar and phasor forms. It includes func-
tions for adding, subtraction, multiplication and division of phasors, plotting phasors on the
complex plane and in the time domain and many useful analysis.

1. INTRODUCTION

DC and AC circuit analysis is the beginning and the fundamental course in the Engineer-
ing/Technology programs. In this or similar courses, students learn to analyze electrical circuits
and networks by using basic electrical engineering laws like the Ohm’s law, Kirchoff’s laws,
component relations and impedance formulae for sinusoidal signals. This analysis generally
uses three steps, a) gather the given data from the word statements and list the expectations, b)
use basic laws to set up the equations and steps for the analysis and c) do the calculations and
plots if necessary by using formulae, mathematical tools and help at the disposal of the learner.
In the last step most students and instructors and textbooks prefer to use calculators, but it is
usually a long drawn procedure and often fraught with errors. In long calculations, the students
often loose attention while their immediate concerns become not to commit mathematical mis-
takes. As a consequence, they do not pay enough attention on the concepts and the underlying
reasons for doing what they are doing. This paper presents a MATLAB based Toolbox to do
most of these calculations and help in fortifying the conceptual learning. Students learn to use
MATLAB functions just like the mathematical formulae. The graphical displays from the tool
box further enhances understanding.

2. PHASOR TOOL BOX

The proposed tools are designed with two objectives in mind a) to understand how to write
MATLAB codes to solve a problem using standard MATLAB functions and those in the pro-
posed toolbox, and b) to visualize the results graphically.

The toolbox contains functions that will perform most of the tasks encountered in ac and dc cir-
cuit analysis:

Conversion functions: such as the complex to polar and phasor and back.
Math operations on phasors/polar variables:
add, subtract, multiply and divide.
Complex plane plots: of polar and phasor quantities
Time domain plots of phasors
Series-Parallel network: determining voltage and current in all components and finding
input impedances.
Thevenin and Norton equivalent circuits
Power calculations: in single and three phase circuits
Full list of functions is as the following:

MATLAB function Description


1 x2p(x) Conversion from Complex to Polar form, x is a single complex value or
an array of complex values
2 p2x(p) Conversion from Polar to Complex form, P is a single polar quantity or
an array of polar quantities
3 x2ph(x) Conversion from Complex to Phasor form, x is a single complex value
or an array of complex values
4 ph2x(A) Conversion from Phasor to Complex form, A is a single phasor or an ar-
ray of phasors
5 p_conj(P) Conjugate of a phasor in polar form (V*), P is a single phasor/polar
quantity or an array of phasor/polar quantities
6 p_add(A) Addition of polar/phasor quantities, A is an array of polar/phasor quan-
tities
7 p_sub(A, B) Subtract the polar/phasor B from polar/phasor A
8 p_mult(V) Multiply polar/phasor quantities, V is an array of polars/phasors
9 p_div(A, B) Divide the polar/phasor A by B
10 xplot(V) Plot complex quantity on the complex plane, V is an array of complex
quantities
11 xplot_signal( x, f, t1, t2 ) Plot of complex variable x of frequency f in time domain, over a range
of time between t1 and t2, x may be a single complex variable or an ar-
ray of complex variables.
12 phplot(V) Plot of phasor on the complex plane, V is a single phasor or an array of
phasors
13 phplot_signal (V, f, t1, t2 ) Plot of phasor V of frequency f in time domain, over a range of time be-
tween t1 and t2, V may be a single phasor or an array of phasors.
14 parallelZ (Z) Parallel combination of two or more impedances, Z is an array of im-
pedances in complex form
15 inputZ (Z, V) Input impedance in complex form across a-a’ terminals of the voltage V
in a network that has an impedance matrix Z
16 power_ph(V, I) Calculate the apparent power VA, VAR, Real Power and power factor,
V and I are voltage and current phasors into an element or a subnetwork
17 Pf(PT, QT) Calculate the power factor in a 1-phase network that consumes real
power PT and reactive power QT.
18 power_ph3(V, I) Calculate apparent power S, reactive power Q and the real power P, the
power factor Fp in a 3-phase network, V and I are column of phasors in
all 3 phases.
19 line2phase( EAB, EBC, Line voltage to phase voltage converter in 3-phase ac circuits
ECA)
20 phase2line(Ean, Ebn, Ecn) Phase voltage to Line voltage converter in 3-phase ac network
21 Thevenin(Z, V, k) Find the Thevenin equivalent circuit across a-a’ terminals in a network,
Z is the impedance matrix with terminals a-a' shorted, V is source vector
with a-a' shorted, k is the array of the loop # where terminals a-a' are lo-
cated, negative loop number indicates that the loop current enters the a
terminal positive loop number indicates that the loop current leaves the
a terminal.
22 delta2wye(ZA, ZB, ZC) Delta to Wye network impedance converter in complex form
23 wye2delta(Z1, Z2, Z3) Wye to Delta network impedance converter in complex form
24 pwr_triangle(P, Q) Draw the power triangle, the real power P and the reactive power Q in
the polar form as the base and the height and the apparent power S as
the hypotenuse of the triangle, also calculates the power factor.
MATLAB is basically designed for operations on matrices and complex numbers. The toolbox
specifies a complex quantity (3+j4) and its graphical plot as

C= 3+j*4; % C is a complex quantity


xplot(C) %Complex quantity C
% on the complex-plane
grid

Fig. 1 Complex quantity C on the complex plane

A general vector is a directed arrow from point a (x1, y1) to another point b (x2, y2) on the complex
plane. Plot of a vector on the complex plane is obtained in the MATLAB from the code
axis([-6, 6, -6, 6])
arrow([1, 2], [4, -4])
grid

Fig. 2 A vector on the complex plane

In ac circuits, an ac voltage signal is given by: 𝑣(𝑡) = 𝑉 sin(𝜔𝑡 + 𝜃)

If the frequency  is constant, the signal amplitude varies in a sinusoidal manner as time proceeds.
The voltage amplitude at any time t1 can be represented by

𝑣(𝑡 = 𝑡1 ) = 𝑉1 = 𝑉 cos(𝜔 𝑡1 + 𝜃) + 𝑗 𝑉 sin(𝜔 𝑡1 + 𝜃)

Since  is constant, we can assume it to be zero without loss of any information, then V1 can be
treated as a complex quantity:

𝑉1 = 𝑉 cos 𝜃 + 𝑗 𝑉 sin 𝜃 in MATLAB: V1=V*cos(th)+j*V*sin(th);

or by a polar vector of length V from the origin, rotating counterclockwise on the complex plane in
a circle with the center at the origin:

𝑉1 = 𝑉 𝑒 𝑗𝜃 where  is denoted in radians in MATLAB: V1=V*exp(j*th)

or in ac circuit analysis by a column vector,

𝑉1 = 𝑉 ∠𝜃 where  is expressed in degrees.


𝑉
in MATLAB: [ ] or [𝑉 ; 𝑡ℎ]
th

the magnitude V is expressed in rms, the vector V1 is called the phasor. The term phasor is reserved
for expressing the sinusoidal voltage or current in polar vector format but with rms (root mean
square) magnitude. Thus, a vector from origin, point ‘o’ (0, 0) to a point a (x, y), is called a polar
vector or a phasor.

Phasor:
Plot of a phasor on the complex plane is obtained from

phplot([Ph])

The function phplot () should give the graph identical


to the one obtained from cxplot().

Fig. 3 A phasor on the complex plane

Form conversions:

Complex to polar: Po=x2p(3+j*4) result is Po=[5 ; 53.13]

Complex to phasor: Ph=x2ph(3+j*4) result is Ph=[3.53 ; 53.13]

3. ILLUSTRATIVE EXAMPLES OF AC CIRCUIT ANALYSIS

3.1 EXAMPLE of R-L-C Circuit

Calculate and draw the phasor diagrams, and time domain waveforms for I, VR, VL and VC in the
following circuit where R=2 ohms, L=1 mH, and C=1000 µF. Assume the frequency is 60 Hz.

Fig. 4 A R-L-C circuit

%source: Boylestad, Fig. 15.39, Page 669


clf
Ep=[50; 0]; %phasor E
Ex=ph2x(Ep) % E in complex form
f=60; T=1/f;
R=2; L=10e-3; C=10e-3;
XL=2*pi*f*L; XC=1/(2*pi*f*C);
Zx=R+j*XL-j*XC;
Ix=Ex/Zx %current I in complex form
Ip=x2ph(Ix) %current I in phasor form
subplot(211)
phplot([Ep, Ip]);
grid
subplot(212)
%time domain waveforms of phasors
%E and I
phplot_signal([Ep, Ip], f, 0, 2*T);
grid

Fig. 5 Phasors and waveforms in the R-L-C


circuit

3.2 EXAMPLE OF VOLTAGE AND CURRENT IN A NETWORK

Find currents I1, I2, and the input impedance seen by sources E1 and E2.

%source: Boylestad, Ex 18-10, Fig. 18.16, page 787


%express all E, Z and I in the complex form
clf
Z1=0.5+j*1; Z2=4-j*8; Z3=j*6;
f=60; T=1/f;
E1p=[8; 60];
E2p=[10; 0];
E1=ph2x(E1p);
E2=ph2x(E2p);
E=[E1+E2; -E2]; % E is a column vector
Z=[Z1+Z2, -Z2
-Z2, Z2+Z3 ];
Fig. 6 A Mesh network
%solution for loop currents
I=Z\E %Solution of Z I=E equations
I1p=x2ph(I(1)) %current I1 in polar form
I2p=x2ph(I(2)) %current I2 in polar form
subplot(411)
phplot([E1p, I1p]);
subplot(412)
phplot_t([E1p, I1p], f, 0, 2*T);
subplot(413)
phplot([E2p, I2p]);
subplot(414)
phplot_signal([E2p, I2p], f, …
0, 2*T);
%input impedance as seen by source E1 .
ET1=[E1; 0];
%set E2=0 in E
ZT11=inputZ(Z, ET1);
ZT1p=x2p(ZT1)
%input impedance as seen by source
E2
ET2=[E2; -E2];
%set E1=0
ZT2=inputZ(Z, ET2);
ZT2p=x2p(ZT2)

Fig. 7 Phasors and waveforms in Fig 6

3.3 EXAMPLE OF MAXIMUM POWER TRANSFER

Find the Thevenin equivalent circuit as seen by ZL and the maximum power delivered to it.

%source: Boylestad, Ex 19-20, Fig.


19.85, page 849)
clf
Z1=j*9; Z2=8;
Ep=[10; 0]; %E as phasor
Ex=ph2x(Ep); %E in the complex
form
%Write Z matrix with the terminals
a-a' shorted
V=[Ex; 0; 0];
Z=[Z1, -Z1, 0
-Z1, Z1+Z1+Z1, -Z1 Fig. 8 Maximum Power transfer in Bridge network
0, -Z1 , Z1+Z2];
k=[-1, 3]; %parameter k in thevenin
[Eth, Zth]=Thevenin(Z, V, k );
Ethp=x2ph(Eth) % Thevenin voltage
Zthp=x2p(Zth) % Thevenin impedance
% ZL for for max power transfer
ZL=conj(Zth)
ZLp=p_conj(Zthp)
Pmax=Ethp(1)^2/(4*real(Zth))
phplot([Zthp, ZLp]);
grid

Fig. 9 The Thevenin and the load im-


pedances in the complex plane at maxi-
mum power transfer
3.4 EXAMPLE OF SUPERPOSITION OF SOURCES WITH DIFFERENT
FREQUENCIES

E1 and E2 are respectively the 100 Hz and 200 Hz sources. Find the current I in the middle branch
and plot its waveform. The inductors L1 = 6.4 mH, L2 = 6.4 mH, and the capacitor C= 500 µF.

Fig. 10 A circuit with sources of different frequencies

%source: Boylestad, Fig. 19.15, page 822


%ECET15200_ch19_1B
clf
f1=100; f2=200;
L1=.0064; L2=L1; C=5e-4;
Z1=j*2*pi*f1*L1; Z2=Z1; Z3=-
j/(2*pi*f1*C);
Z12=Z1*f2/f1;
Z22=Z2*f2/f1;
Z32=Z3*f1/f2;
E1p=[10;0]; E2p=[5; 0];
E1=ph2cx(E1p); E2=ph2cx(E2p];
Is1=E1/(Z1+parallelZ([Z2, Z3]))
I1_1=Z3*Is1/(Z2+Z3)

Is2=E2/(Z32+parallelZ([Z12, Z22])) Fig. 11 Waveforms in the circuit of Fig. 10


I1_2=Z12*Is2/(Z12+Z22)
subplot(311)
[y1, t1]=xplot_signal(I1_1, f1, 0, 0.02);
subplot(312)
[y2, t2]=xplot_signal(I1_2, f2, 0, .02);
subplot(313)
plot(t1, y1+y2) %superposed current

3.5 EXAMPLE OF 3-PHASE -GENERATOR, Y- LOAD

Find the total average, reactive and apparent power and the power factor.
Fig. 12 3-phase -generator, Y- load

%source: Boylestad, Ex 24-6, Fig. 24.25, page 1094


clf
f=60; T=1/f;
%Delta Load
EAB=[200; 0]; EBC=[200; -120]; ECA=[200; -240]; %Line voltages
Ed=[EAB, EBC, ECA];
Zab=x2p(6-j*8); Zbc=Zab; Zca=Zab; %impedances in the Delta Load, converted to the complex…
form
%Calculation of Line currents in the Delta load
Idab=p_div(EAB, Zab); Idbc=p_div(EBC, Zbc); Idca=p_div(ECA, Zca);
Id=[Idab, Idbc, Idca];
[STd, QTd, PTd]=power_ph3d(Ed, Id) %apparent, reactive and the average power in the Delta load

%Y-load calculations
Zan=x2p(4+j*3); Zbn=Zan; Zcn=Zan;
[Van, Vbn, Vcn]=line2phase(EAB, EBC, ECA)
V=[Van, Vbn, Vcn];
Ian=p_div(Van, Zan); Ibn=p_div(Vbn, Zbn); Icn=p_div(Vcn, Zcn);
I=[Ian, Ibn, Icn];
[STy, QTy, PTy]=power_ph3d(V, I) %apparent, reactive and the average power in the Y- load

%full load calculations


PT=p_add([PTd, PTy])
QT=p_add([QTd, QTy])
[ ST, Fp, phase]=pwr_triangle(PT, QT )
Fig. 13 The apparent, reactive and the average power in the 3-phase -generator, Y- load

4. PLAN OF IMPLEMENTATION

The phasor toolbox was developed while teaching the class in the Fall semester of 2017. It is
planned to use the tool in ECET 15200: AC Circuit Analysis, ECET 21200: Electrical Power and
Machinery, and ECET 41200: Electric Drives in the future semesters in the Electrical Engineering
Technology undergraduate program. We plan to look at the effect on the content delivery and assess
the benefits of instruction by utilizing the Phasor Tool Box. All user defined functions will be made
available to those who ask for them.

5. SUMMARY

This paper presents a MATLAB phasor toolbox for analyzing ac sinusoidal circuits in the Electrical
and Computer Engineering Technology program. The toolbox has functions for conversion among
complex, polar and phasor forms, for adding, subtraction, multiplication and division of phasors,
plotting phasors on the complex plane and in their waveforms in the time domain. The toolbox also
enables the calculation of Thevenin equivalent circuits, input impedances in networks, and calcula-
tion of apparent, reactive and real power in single and 3-phase ac circuits. The toolbox has the ca-
pability of analyzing ac circuits with sources of different frequencies. It is also capable of drawing
Power Triangle diagrams and power factors in 3-phase networks.

References
[1] “Introductory Circuit Analysis” Robert Boylestad, 13th ed., Pearson Education Inc.
[2] MATLAB v. 2017b, Mathworks Inc.

You might also like