Spherical Coordinates Matlet

Spherical Coordinates Matlet

Published by Arun Isaac on

Tags: math, matlab, software

This "matlet" is work we did for an assignment we had in the third semester on Electromagnetic Fields. The problem statement was to create an applet which could plot surfaces in the spherical coordinate system.

A 3D spherical coordinates plot of r(phi, theta) = sin(theta) is on the left. Controls to change the expression for r and the range of phi and theta are seen on the right.

Figure 1: Screenshot of the Matlet

This "matlet" is work we did for an assignment we had in the third semester on Electromagnetic Fields. The problem statement was to create an applet which could plot surfaces in the spherical coordinate system. The idea was for the applet to be put up online to serve as a teaching aid for spherical coordinate systems (commonly used to represent electromagnetic vector fields).

So, we set about coding it as a "matlet" in Matlab. We had to do a little reading up of the Matlab documentation and revise our own concepts of the spherical coordinate systems, but we managed to code a fairly robust, user-friendly matlet which could take any user-defined spherical coordinate system function and plot it. We even built an intuitive, easy to use GUI for it. The image is a screenshot of the GUI with an interesting "doughnut function" plotted in it.

So far so good and we were indeed very pleased with our efforts. However our attempts to compile the Matlab 'm files' into a standalone Java applet we could put on a web page failed. Apparently, the Matlab Compiler does not compile the Symbolic Math Toolbox, which was the corner stone of our expression parsing. And even if we did succeed in making up for that, the "applet" would still be burdened with a huge, nearly 200 MB download of Matlab Compiler Runtime, a prerequisite for running the compiled application. Well, that's what I call proprietary crap!

Recoding the applet in Java was not really an option considering that we knew too little about Java and learning a whole new language would be rather expensive on time and resources. So, the project has been suspended indefinitely. Perhaps the only silver lining is that you can download the source (below) and if you have Matlab, execute the program.

You may also download the PDF of the OHP presentation we made in class for the assignment. It says a little about the implementation of the applet in Matlab.