MATLAB-Based EM Notaros Contents Preface
MATLAB-Based EM Notaros Contents Preface
Electromagnetics
Branislav M. Notaroš
Department of Electrical and Computer Engineering
Colorado State University
Boston Columbus Indianapolis New York San Francisco Upper Saddle River
Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto
Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
Vice President and Editorial Director, ECS: Marcia J. Horton
Executive Editor: Andrew Gilfillan
Editorial Assistant: William Opaluch
Executive Marketing Manager: Tim Galligan
Marketing Assistant: Jon Bryant
Permissions Project Manager: Karen Sanatar
Senior Managing Editor: Scott Disanno
Production Project Manager / Editorial Production Manager: Greg Dulles
Cover Designer: Suzanne Behnke
c 2014 by Pearson Education, Inc. Pearson Prentice-Hall, Upper Saddle River, NJ 07458. All rights reserved.
No part of this book may be reproduced in any form or by any means, without permission in writing from
the publisher. The author and publisher of this book have used their best efforts in preparing this book.
These efforts include the development, research, and testing of the theories and programs to determine their
effectiveness. The author and publisher make no warranty of any kind, expressed or implied, with regard to
these programs or the documentation contained in this book. The author and publisher shall not be liable
in any event for incidental or consequential damages in connection with, or arising out of, the furnishing,
performance, or use of these programs.
ISBN-10: 0-13-285794-4
ISBN-13: 978-0-13-285794-9
CONTENTS
1 Electrostatic Field in Free Space 1
1.1 Coulomb’s Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Electric Field Intensity Vector Due to Given Charge Distributions . . . . . . . . . 9
1.3 Electric Scalar Potential . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
1.4 Differential Relationship Between the Field and Potential in Electrostatics, Gradient 26
1.5 Electric Dipole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
1.6 Gauss’ Law in Integral Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
1.7 Differential Form of Gauss’ Law, Divergence . . . . . . . . . . . . . . . . . . . . . . 31
1.8 Method of Moments for Numerical Analysis of Charged Metallic Bodies . . . . . . 33
10.10 Step Response of Transmission Lines with Purely Resistive Terminations . . . . . 267
10.11 Analysis of Transmission Lines with Pulse Excitations . . . . . . . . . . . . . . . . 272
10.12 Bounce Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
10.13 Transient Response for Reactive Terminations . . . . . . . . . . . . . . . . . . . . 286
Bibliography A-22
Index A-25
MATLAB
R
-Based Electromagnetics ix
PREFACE
Electromagnetic theory is a fundamental underpinning of technical education, but, at the same
time, one of the most difficult subjects for students to master. In order to help address this
difficulty and contribute to overcoming it, here is a textbook on electromagnetic fields and waves
completely based on MATLAB
R
, and so entitled, simply, MATLAB
R
-Based Electromagnetics.
This text provides engineering and physics students and other users with an operational knowledge
and firm grasp of electromagnetic fundamentals aimed toward practical engineering applications,
by teaching them “hands on” electromagnetics through a unique and comprehensive collection of
MATLAB computer exercises and projects. Essentially, the book unifies two themes: it presents
and explains electromagnetics using MATLAB on one side, and develops and discusses MATLAB
for electromagnetics on the other.
The book is designed primarily (but by no means exclusively) for junior-level undergraduate stu-
dents in electrical and computer engineering, physics, and similar departments, for either two-
semester course sequences or one-semester courses, and/or equivalent quarter arrangements. How-
ever, it can also be used earlier and later in the curriculum. It covers all important theoretical
concepts, methodological procedures, and solution tools in electromagnetic fields and waves for
undergraduates – organized in 12 chapters on electrostatic fields; steady electric currents; magne-
tostatic fields; time-varying electromagnetic fields; uniform plane electromagnetic waves; transmis-
sion lines; waveguides and cavity resonators; and antennas and wireless communication systems.
It largely follows the organization of Electromagnetics by Branislav M. Notaroš, published in 2010
by Pearson Education.
On the other hand, the book allows for flexibility in coverage of the material, including the
transmission-lines-early and transmission-lines-first approaches. Namely, Chapter 10 (Circuit Anal-
ysis of Transmission Lines) discusses only pure circuit-theory concepts, so that it can be taken at
any time, along with Sections 6.7 and 6.8, which introduce phasors and complex representatives of
time-harmonic voltages and currents.
MATLAB
R
-Based Electromagnetics is a self-contained textbook that can be used either as a sup-
plement to any available electromagnetics text (e.g., [1]–[17] in the Bibliography) or as an inde-
pendent resource. In other words, it is designed either to complement another (currently used or
to be adopted) textbook and a variety of teaching styles, as a comprehensive companion adding
a very significant MATLAB component to the course, or to serve as a principal resource for a
MATLAB-based electromagnetic fields and waves course. In either way, MATLAB exercises are
designed to strongly enforce and enhance both theoretical concepts and problem-solving techniques
in electromagnetics.
In addition, respective parts of almost all chapters of the book can be effectively incorporated
in higher-level courses on antennas, microwave theory and engineering, wave propagation and
guidance, advanced electromagnetic theory, computational electromagnetics, electrical machines,
x Contents, Preface, and m Files on Instructor Resources
signal integrity, etc. (for instance, see [18]–[34]). Furthermore, the book may be used by students
outside of any particular course arrangements and by practicing engineers and scientists as well
– to review and solidify the knowledge of fundamentals of electromagnetic fields and waves or
certain aspects of electromagnetic theory and applications, now in a MATLAB context. Some may
use it, on the other hand, to build and enhance the understanding and command of MATLAB
syntax, functionality, and programming, in the framework of electromagnetics. Finally, because
of its project-based philosophy and format, the book may be useful for distance learning, online
courses, and other forms of nontraditional course delivery.
• The book provides two interwoven themes: presentation and study of electromagnetics using
MATLAB and development and discussion of MATLAB for electromagnetics
• Contains 389 MATLAB computer exercises and projects, covering and reinforcing practi-
cally all important theoretical concepts, methodologies, and problem-solving techniques in
electromagnetic fields and waves (see Appendix 3 for a full List of MATLAB Exercises)
• Designed primarily for undergraduate electromagnetics, but can also be used in follow-up
courses on antennas, propagation, microwaves, advanced electromagnetic theory, computa-
tional electromagnetics, electrical machines, signal integrity, etc.
• Provides a theoretical overview at the start of each section within each chapter of the book
• Maintains a favorable balance of MATLAB exercises between static (one third) and dynamic
(two thirds) topics
• Offers MATLAB exercises at all levels of difficulty, from a few lines of MATLAB code, to
those requiring a great deal of initiative and exploration
• Contains 125 TUTORIALS with detailed solutions merged with listings of MATLAB codes
(m files); a demo tutorial for every class of MATLAB problems and projects is provided
• Gives 98 HINTS with guidance on the solution, equations, and programming, often with
portions of the code and/or resulting graphs and movie snapshots for validation
• Features 48 3-D and 2-D movies developed and played in MATLAB, which are extremely
valuable for interactive visualizations of fields and waves
• Displays 133 figures generated in MATLAB with plots of geometries of structures, vector
fields, guided and unbounded waves, wave polarization curves, Smith charts, transient sig-
nals, antenna patterns, etc.
• Presents 16 graphical user interfaces (GUIs) built in MATLAB to calculate and display
parameters and characteristics of various electromagnetic structures, materials, and systems,
selected from a pop-up menu
MATLAB
R
-Based Electromagnetics xi
• Offers 130 MATLAB exercises recommended to be done also “by hand” – i.e., not using
MATLAB, thus serving as traditional written problems
MATLAB
R
(by MathWorks, Inc.) is chosen not only for its very high quality and versatility, but
because it represents a generally accepted standard in science and engineering education worldwide
(e.g., [35]–[44]). Assignments of computer exercises along with traditional “by hand” problems help
students develop a stronger intuition and a deeper understanding of electromagnetics. Moreover,
this approach actively challenges and involves the student, providing additional benefit as compared
to a passive computer demonstration. This book provides abundant opportunities for instructors to
assign in-class and homework projects, and for students to engage in independent learning. MAT-
LAB exercises are also ideal for interactive in-class explorations and discussions (active teaching
and learning), and for team work and peer instruction (collaborative teaching/learning).
On the other side, studying and practicing these diverse exercises allows students to gain com-
prehensive and operational knowledge and skills in concepts and techniques of MATLAB use and
programming. These skills can then be used effectively and implemented in other areas of study,
including other courses in the curriculum.
To make this text self-contained and easy to use, each section within each chapter begins with a brief
theoretical overview, which is followed by MATLAB exercises strongly coupled to the theory. Some
theoretical details, along with abundant applications, are introduced through exercises themselves.
Each book section contains a large number of tutorial exercises with detailed solutions merged with
listings of MATLAB codes (m files). TUTORIALS explain every step, with ample discussions of
approaches, programming strategies, MATLAB formalities, and alternatives. They are written
so that even a reader with no prior experience with MATLAB can fully understand them. Most
importantly, all new concepts, approaches, and techniques in MATLAB programming as applied to
electromagnetic fields and waves are covered with TUTORIALS. With a total of 125 TUTORIALS,
for each class and type of MATLAB problems and projects there is always a demo exercise or set of
exercises with complete detailed tutorials and code listings to provide students with guidance for
completing similar exercises on their own. This is especially notable for exercises of intermediate
and advanced levels of difficulty.
In addition to exercises with TUTORIALS, there are 98 exercises with HINTS, which provide
guidance on the solution, equations, and programming, sometimes with most critical portions
of MATLAB codes for the problem. In many cases, they present the resulting graphs and movie
snapshots, so that readers can see what exactly they are expected to do and can verify and validate
their codes. The exercises include 48 movies developed and played in MATLAB, 133 figures
generated in MATLAB, and 16 GUIs built in MATLAB.
However, even the exercises with TUTORIALS can be assigned for homework or classwork, as
their completion requires putting together a MATLAB code from the provided portions of the code
listing (note that in some tutorials, some standard parts of the code, like data input, are omitted);
actual running of the code; and generation and presentation of results. It is recommended that
these exercises be a part of every homework assignment.
xii Contents, Preface, and m Files on Instructor Resources
MATLAB exercises require a great deal of analytical preparation, manipulation with equations,
and conceptual, strategic, and calculative analysis of problem situations. Thus, they are a great
complement or often an adequate substitute for traditional written problems. Moreover, 130 ex-
ercises are designated as two-purpose problems: as computer-based MATLAB problems and as
conventional “by hand” computational problems (these exercises are marked by H in the book). Of
course, the reader can compare and cross-validate the results from MATLAB and those obtained
“by hand.” In addition, these problems (and their variations) can be given as traditional problems
for homework and on exams. Note, however, that many other (unmarked) exercises can entirely,
or in large part, be solved without MATLAB. In general, solving the problems and studying the
topics both analytically and using MATLAB is most beneficial.
MATLAB codes described (and listed) in TUTORIALS or proposed in other exercises provide
prolonged benefits of learning. By running codes; generating results, figures, and diagrams; playing
movies and animations; and solving a large variety of problems in MATLAB, in class, with peers
in study groups, or individually, students gain a deep understanding of electromagnetics. Most
importantly, this book capitalizes on a win-win combination of pedagogical benefits of MATLAB-
based electromagnetics education and students’ computer-related skills and interests. As opposed
to other available electromagnetics texts that feature some use of MATLAB, this text is by far
the most complete and ambitious attempt to use MATLAB across all elements of electromagnetics
education.
⋄ MATLAB codes for computing and plotting electric and magnetic forces and fields (vectors)
due to arbitrary 3-D arrays of stationary and moving charges; movie of electron travel in a
magnetic field
⋄ Calculation and visualization of boundary conditions for oblique and horizontal boundary
planes between arbitrary media, without and with surface charges/currents on the plane
⋄ Calculations and movies of electromagnetic induction due to moving and rotating loops in
various magnetic fields
⋄ Graphical representation of complex numbers and movies of voltage and current phasor
rotation in the complex plane
⋄ Symbolic computation of E and H fields and transmitted power for arbitrary TE and TM
modes in a rectangular metallic waveguide, and of fields and stored energy in a rectangular
cavity resonator
⋄ 2-D and 3-D movies visualizing attenuated and unattenuated traveling and standing uniform
plane electromagnetic waves in different media
MATLAB
R
-Based Electromagnetics xiii
⋄ 2-D and 3-D movies and plots of circularly polarized (CP) and elliptically polarized (EP)
waves; analysis and movie visualization of changes of wave polarization and handedness due
to travel through anisotropic crystals
⋄ 3-D and 2-D movies of incident, reflected, and transmitted (refracted) plane waves for both
normal and oblique incidences on both perfectly-conducting and dielectric boundaries, tran-
sient processes and steady states
⋄ Computation and visualization in MATLAB of angular dispersion of a beam of white light
into its constituent colors in the visible spectrum using a glass prism
• Symbolic and numerical programming in MATLAB:
⋄ Symbolic differentiation and integration in all coordinates, symbolic Maxwell’s equations,
volumetric power/energy computations, conversion from complex to time domain, radiation
integrals, etc.
⋄ Numerical differentiation and integration, various types of finite differences and integration
rules, vector integrals, Maxwell’s equations, optimizations, numerical solutions to nonlinear
equations, etc.
• Field and circuit analysis of transmission lines in MATLAB:
⋄ GUI for primary and secondary circuit parameters of multiple transmission lines
⋄ MATLAB analysis and design (synthesis) of microstrip and strip lines with fringing
⋄ Numerical solutions and complete designs in MATLAB of impedance-matching transmission-
line circuits with shunt and series short- and open-circuited stubs, including finding the stub
location
• Transmission-line analysis and design using the Smith chart in MATLAB:
⋄ Construction of the Smith chart in MATLAB, adding dots of data on the chart, movies of
Smith chart calculations on transmission lines, movies finding load impedances using the
Smith chart
⋄ Searching for a desired impedance along a line in a numerical fashion and complete design
in a Smith chart movie of impedance-matching transmission-line circuits with series stubs
• MATLAB calculation of transients on transmission lines with arbitrary terminations:
⋄ General MATLAB code for calculation of transients on transmission lines; plotting tran-
sient snapshots and waveforms; transient responses for arbitrary step/pulse excitations and
matching conditions
⋄ Numerical simulation in MATLAB of a bounce diagram: bounce-diagram matrix; extracting
signal waveforms/snapshots from the diagram; complete MATLAB transient analysis using
bounce diagrams
⋄ Complete transient analysis in MATLAB of transmission lines with reactive loads and pulse
excitation, with the use of an ordinary differential equation (ODE) solver; generator voltage
computation
xiv Contents, Preface, and m Files on Instructor Resources
• MATLAB analysis and visualization of antennas, wireless systems, and antenna arrays:
⋄ Computation of the near field, radiation integral, far field, radiation and ohmic resistances,
radiation efficiency, directivity, and gain of wire antennas
⋄ Functions in MATLAB for generating 3-D polar pattern plots of arbitrary radiation functions
and for cutting a 3-D pattern in three characteristic planes to obtain and plot 2-D polar
radiation patterns
⋄ Playing a movie to visualize the dependence of the radiation pattern on the electrical length
of wire antennas
⋄ 3-D visualization of a wireless system with arbitrarily positioned and oriented wire dipole
antennas; complete MATLAB analysis of systems with nonaligned antennas, including CP
and EP transmitting antennas
⋄ Computation of the array factor of arbitrary linear arrays of point sources, generation of 3-D
radiation pattern plots and 2-D pattern cuts in characteristic planes; complete MATLAB
analysis of linear arrays
⋄ Implementation and visualization of the pattern multiplication theorem for antenna arrays
in xy-, xz-, and yz-planes; complete MATLAB analysis of uniform and nonuniform arrays
of arbitrary antennas (not just point sources)
⋄ MATLAB codes based on the method of moments (MoM) for 3-D numerical analysis of
charged metallic bodies (plates, boxes, and a parallel-plate capacitor); preprocessing and
postprocessing
⋄ MATLAB codes for 2-D finite-difference (FD) numerical solution of Laplace’s equation, based
on both iterative and direct solutions of FD equations; potential, field, and charge compu-
tations
Pearson eText of the book, with full-color figures, is available on the Companion Website (CW):
www.pearsonhighered.com/notaros
I thank the reviewers of the manuscript for their extremely detailed, useful, and competent com-
ments, which helped me to improve the quality of the book, including: Prof. Jacob Adams, North
Carolina State University; Prof. Charles F. Bunting, Oklahoma State University; Prof. Gregory
David Durgin, Georgia Institute of Technology; Prof. Ahmed Helmy, University of Florida;
MATLAB
R
-Based Electromagnetics xv
Dr. Ming-Shih Huang, Penn State University; Prof. Leo C. Kempel, Michigan State University;
Prof. Sudarshan R. Nelatury, Penn State University; Prof. L. Wilson Pearson, Clemson Univer-
sity; Prof. Ahmad Safaai-Jazi, Virginia Tech; Prof. Ergun Simsek, George Washington University;
Prof. Jing Wang, University of South Florida; and Prof. Y. Ethan Wang, University of California,
Los Angeles.
I am grateful to my Pearson Prentice Hall editor Andrew Gilfillan, who has been very helpful and
supportive, and whose input was essential at many stages in the development of the book.
I would like to acknowledge and express special thanks and sincere gratitude to my Ph.D. students
Ana Manić, Nada Šekeljić, and Sanja Manić for their truly outstanding work and invaluable help
with writing MATLAB computer exercises, tutorials, and codes.
All listed MATLAB codes and parts of codes may be used only for educational purposes associated
with the book, MATLAB
R
-Based Electromagnetics.
Branislav M. Notaroš
Fort Collins, Colorado
xvi Contents, Preface, and m Files on Instructor Resources
There are about 560 m files – for 389 MATLAB exercises; some exercises have multiple m files,
as their solutions consist of more than one function or the main program and a function, etc.
Files with functions (written in MATLAB) have descriptive names, e.g., bounceDiagram.m. Files
with main MATLAB programs are named according to the numeration/labeling of exercises: for
instance, main program for MATLAB Exercise 12.32 is in file ME12 32.m. So, the “recipe” for
finding the m file for a given MATLAB exercise is simple: (1) if the exercise features a main
MATLAB program, find the m file with the name matching the exercise label (number) in the
respective chapter folder; (2) in the case of a function exercise, look for the function name in the
statement of the exercise, and find the m file with that name. For convenience, however, the names
of respective m files are explicitly specified in all MATLAB exercises in the book. List of MATLAB
Exercises in Appendix 3 contains the full list of m files as well.
Files for GUIs built in MATLAB are stored in separate folders (subfolders) named after the corre-
sponding MATLAB exercises, within the respective chapter folders. For example, files for the GUI
from MATLAB Exercise 2.13 are in subfolder ME2 13(GUI) in Chapter 2 folder. A GUI folder
always includes the GUI control function file (e.g., capCalc1.m) and the GUI layout file with the
same name and fig extension (capCalc1.fig). It may also include one or more other functions (m
files), for specific calculations or other tasks. Some GUI folders contain a number of png files (e.g.,
coaxcable.png), with pictures (drawings) of structures (previously created by another computer
program for drawing), which are imported in the GUI control function.
The provided codes are run in MATLAB in a standard fashion: by selecting, opening, and running
the appropriate m file in the appropriate chapter (or GUI) folder.
The material on IR, including all 12 chapter folders with m files, is meant for instructors only. In
addition to serving as a complement to the Instructor’s Solutions Manual for the book, which is
also available on IR, it provides an invaluable resource for lectures, recitations, and class demon-
strations. Namely, any and all MATLAB codes for the current class topic, including codes for
movies; calculators; GUIs; numerical solvers; data processors and tabulators; diagram and fig-
ure plotters; conceptual demonstrators; etc., can readily be run and discussed, in support of a
theoretical presentation, or as a problem session.
Any of the provided m files on Instructor Resources and any of the included MATLAB codes or any
part of a code may be used only for educational purposes associated with the book, MATLAB
R
-Based
Electromagnetics.