Matlab Code Archive 2
About the matlab code archive
Electromagnetic field theory is a complex subject, and there are many different methods one could use to represent a given physical model. Some of these methods are numerical in nature, like the finite-difference time domain (FDTD) method. Other systems have exact, closed-form solutions---for example, light scattering off a cylinder. Whatever the technique, it takes a lot of work to implement the solution into a workable computer code, and it can be a great help to others when that work is shared publicly.
This page contains an archive of useful electromagnetic codes written in MATLAB. It includes both analytic solvers and numerical solvers. There are also many useful mathematical functions and rendering tools.
Matlab codes
The Beauty of Electromagnetics
Utah Man Model and 3D FDTD solver (Fortran)
Misc. Graphical Tools
DrawArrow.m Download DrawArrow.m | Renders a cartoon arrow onto the designated figure. The arrow can be customized for different sizes and styles. |
DrawRectangle.m Download DrawRectangle.m | Renders a solid rectangle onto the designated figure. |
DrawCircle.m Download DrawCircle.m | Renders a solid circle onto the designated figure. |
DrawRing.m Download DrawRing.m | Renders a circular ring onto the designated figure. |
DrawVectorField.m Download DrawVectorField.m | Draws a bunch of arrows onto a figure to represent a vector field. The code includes a bunch of really handy features, like scaling, color, cutoff, etc. |
ULogoVertices.m Download ULogoVertices.m | Create an array of x- and y-coordinates that represent the vertices of the University of Utah's "U" logo. This is fun to have for any marketing/publicity renders. |
@VectorField2D.ZIP Download @VectorField2D.ZIP | Class definition, plus methods, for a vector field profile in 2D. It is similar in purpose to the DrawVectorField.m function above, but with more features. Use this to create beautiful renders of a vector field in 2D, as well as animations. |
Transmission Lines & Microwave Network Solvers
ABCD2Smatrix.m Download ABCD2Smatrix.m | Converts a microwave ABCD matrix into a scattering matrix. |
Smatrix2ABCD.m Download Smatrix2ABCD.m | Converts a 2-port microwave scattering matrix (S-matrix) into the corresponding ABCD matrix. |
LSectionMatchingNetwork.m Download LSectionMatchingNetwork.m | Calculate impedance/admittance for an L-section matching network. |
SeriesStubMatchingNetwork.m Download SeriesStubMatchingNetwork.m | Calculate distance/length for a series stub matching network. |
ShuntStubMatchingNetwork.m Download ShuntStubMatchingNetwork.m | Calculate distance/length for a shunt stub matching network. |
TLineInputImpedance.m Download TLineInputImpedance.m | Equivalent input impedance looking into a transmission line with some fixed load at the end |
CoaxialCableParameters.m Download CoaxialCableParameters.m | Calculate the transmission-line parameters (Z0,C0,L0,G0) for a coaxial cable. |
@Telegrapher1DFDTD.zip Download @Telegrapher1DFDTD.zip | Class definition, plus methods, for a finite-difference time-domain (FDTD) simulation of the Telegrapher's equations (i.e., transmission line). The ZIP file also contains a demonstration script (DemonstrateTransmissionLine1DFDTD.m) that shows how to use the code. For a full tutorial on FDTD with the Telegrapher's equations, see this PDF here Download here. |
Simplified FDTD simulation of the Telegrapher's equations with absorbing boundary condition. |
|
Simplified FDTD simulation of the Telegrapher's equations with physical boundary condition (i.e., open/short). |
|
@Stripline.zip Download @Stripline.zip | Class definition, plus methods, for a stripline/microstrip transmission line model. The ZIP file also contains a demonstration script (RenderMicrostripElectricField.m) that sows how to use it. For a full tutorial on how the calculation works, see this PDF here Download here. |
ProcessTDR.m Download ProcessTDR.m | Compute the time-domain impulse response of a transmission line using Time-Domain Reflectometry (TDR). Input data consists of S11 measurements with a vector network analyzer (VNA). |
https://youtu.be/iXMXbGNox3Q
Links to an external site. Download the code HERE (Links to an external site.). |
FDTD and FDM modeling codes for asymmetric faults in a multiconductor transmission line. Hunter Ellis, Cody LaFlamme, James R. Nagel, Joel Harley, Cynthia M. Furse, "Multiconductor Transmission Lines and Asymmetric Fault in SSTDR Measurements," IEEE Sensors Journal, 2021 |
Download the code here Links to an external site. |
Full system simulation for spread spectrum time domain reflectometry (SSTDR) on a transmission line, or system of sequential transmission lines/loads, using an adapted systematic solution procedure (SSP). |
Electrostatic Field Solvers
UniformCylinderEField.m Download UniformCylinderEField.m | Calculate the electric field intensity around a right circular cylinder of uniform charge density. |
UniformCylinderScalarPotential.m Download UniformCylinderScalarPotential.m | Calculate the electric scalar potential around a right circular cylinder of uniform charge density. |
TwinMetalCylindersEField.m Download TwinMetalCylindersEField.m | Electric field intensity around two symmetric metal cylinders with equal/opposite voltage. |
TwinMetalCylindersScalarPotential.m Download TwinMetalCylindersScalarPotential.m | Electric scalar potential around two symmetric metal cylinders with equal/opposite voltage. |
@Electrostatic2FDM.zip Download @Electrostatic2FDM.zip | Class definition, plus methods, for a two-dimensional electrostatic simulation using the finite-difference method (FDM). The ZIP file also contains a couple of demo scripts that validate the code and show beginners how to use it. For a comprehensive tutorial on how FDM works, see Nagel, 2014 Download Nagel, 2014. |
Magnetostatic Field Solvers
UniformCylinderVectorPotential.m Download UniformCylinderVectorPotential.m | Calculate the magnetic vector potential due to a cylinder of uniform current density. |
UniformCylinderBField.m Download UniformCylinderBField.m | Calculate the magnetic field intensity due to a cylinder of uniform current density. |
MagnetizedBarBField.m Download MagnetizedBarBField.m | Calculate the magnetic field intensity due to an infinite rectangular bar with permanent internal magnetization. |
MagnetizedSphereBField.m Download MagnetizedSphereBField.m | Calculate the magnetic field intensity due to a sphere with permanent internal magnetization along the z-axis. |
Waveguide Solvers
@ParallelPlateWaveguide.ZIP Download @ParallelPlateWaveguide.ZIP | Class definition, plus methods, for an ideal parallel-plate waveguide. The ZIP file also contains a demo script that allows the user freely toy with the model and observe/animate the resulting field profiles. A mathematical tutorial on the basic theory can be found here Download here. |
Plane Waves, Radiation, Propagation, and Scattering
@Maxwell_1DFDTD.zip Download @Maxwell_1DFDTD.zip | Class definition, plus methods, for a transient simulation of Maxwell's curl equations in one dimension using the finite-difference time-domain method (FDTD). The ZIP file also contains a handful of demo scripts that validate the code and show beginners how to use it. Download the tutorial here Download here for a mathematical derivation of FDTD in 1D using Maxwell's equations. I've also included tutorials on numerical dispersion Download numerical dispersion, radiation Download radiation, and the perfectly matched layer Download perfectly matched layer. |
Class definition, plus methods, for a circular cylinder illuminated by a uniform plane wave. Both the cylinder plus ambient medium may have arbitrary material properties (permittivity, permeability, and conductivity). The methods can calculate all the expansion coefficients, plus all scattered and diffracted field profiles. For a tutorial on how the calculation works, see this PDF here Download see this PDF here. The ZIP file also contains a demo script that renders an animation of the total field profile. | |
Calculate attenuation and propagation constants, wavelength for a plane wave in lossy material | |
systematic solution procedure.m Download systematic solution procedure.m |
Systematic Solution Procedure (SSP) for plane waves normally incident on (lossy) layered media (tutorial by Iskander Download tutorial by Iskander). |
Useful Mathematical Tools
SimpsonArea.m Download SimpsonArea.m | Calculate the approximate area under a function by applying Simpson's rule. |
CosCosInt.m Download CosCosInt.m | Calculate the integral of cos(k1*x)*cos(k2*x) from [a,b]. |
srrcImpulseResponse.m Download srrcImpulseResponse.m | Calculates the time-domain impulse response to a square-root-raised-cosine filter. The function is normalized so that convolution with itself results in a standard raised-cosine filter with unit amplitude in the time domain. |
Polar2RectVectors.m Download Polar2RectVectors.m | Converts a vector field from a polar unit-vector basis into rectangular. |
bessel_dj.m Download bessel_dj.m | Calculates the first derivative of the Bessel function of the first kind: J_nu(Z) |
bessel_dh.m Download bessel_dh.m | Calculates the first derivative of the Hankel function: H(NU,Z) |
bessel_dy.m Download bessel_dy.m | Calculates the first derivative of the Bessel function of the second kind: Y_nu(Z) |