This script calculates the electric field and potential within a volume of space due to stacks of rings of point charges, rings sharing a common axis (the z-axis). The point charge density on the rings may be modulated and the ring density may be varied to represent the fields of charge distributions that are discrete of continuous in azimuth or height. Thusly, the user can explore arrays of line charges and tubes withe constant or variable charge density.
Once the charge distribution is set up, the potential and electric fields are calculated in two ways, using MATLAB vectorized methods and using a loop structure, to explore the computation time difference. Visualization techniques include surface plots of the potential and quiver plots of the vector field in sectional planes within the volume.
This script is designed as a tutorial for physics students and contains a variety of Try this suggestions for exploration entailing simple changes in parameter values, and some suggestions for coding extensions at the end. Many of the functions used are hyperlinked to MATLAB documentation for ready reference.