Matlab—A Tool for Doing Numerics
The first time I heard about Matlab was when DOS 3.3 was popular and my dad received a demo version on his PC. I played around with it a bit, but soon lost interest because there was no manual and I did not have any real use for it.
The second encounter was about three years ago when I attended a lecture on numerical mathematics. Some of the exercises the students had to hand in were intended to be solved with Matlab. There was even a handout describing the basic functions of the program. As is usually the case with exercises, numerical homework tends to be very time-consuming, so again I did not spend much time on it. Soon thereafter, I installed Linux on my then new PC.
The third time I came into contact with Matlab was during my diploma thesis. All serious data evaluation in the group where I worked was done using Matlab—not on UNIX, but on a Macintosh.
I asked whether I could bring my until-then “unplugged” Linux box to the lab and network it. I got an IP number and a weekend later the first Linux computer of our group was up and running.
Campus licenses are available for various software and I was quite happy to find Mathematica, Maple and Matlab for Linux. Shortly afterwards, I was running the already-existing Mac-Matlab scripts on my computer.
Matlab is a command-line-driven program specializing in all types of matrix manipulation. Everything in Matlab is expressed using matrices; even a scalar can be thought of as a 1x1 matrix.
The first noncommercial version of Matlab was based on LINPACK and EISPACK routines. Since then, much has changed and Matlab is now one of the fastest packages available for numerical computation.
When Matlab is started in an xterm, a prompt appears after a brief display of the logo in a separate window. Basic editing is possible, though the spoiled Linux user might miss tab completion. (A sophisticated tab-completion feature recognizing file names would be great.)
A nice feature of Matlab is the ability to cluster data into compounds similar to structs in C, but it is not necessary to define them in advance. One simply adds fields to a variable, i.e., data.Temp might be the temperature at which a measurement was taken, and data.B is a vector containing the values of the magnetic field at which the Hall resistivities data.rxy were measured. Adding a string data.date='July-4th-1999' is not a problem, either. Going a step further, it is even possible to use object-oriented features.
For complex tasks involving more than two or three commands, one can write scripts or functions. The difference between them is that scripts are executed as if they were typed at the command prompt, whereas functions use private memory with local and global variables, and of course, can have multiple return values. The syntax loosely follows C and makes scripting relatively straightforward.
It is even possible to implement graphical front ends for your Matlab application with all different kinds of buttons, sliders and levers, as shown in Figure 1.
The interface used in the Linux version is extremely simple compared to the Windows or Macintosh version. No editor is provided for scripting, so the user has to stick to Emacs or some other editor. I personally use XEmacs in Matlab mode with syntax highlighting. The mode was written by Matt Wette and can be found at ftp.alumni.caltech.edu/pub/mwette/matlab.el. As far as I know, there is even a mode for GNU Emacs which makes it possible to run a Matlab session within the Emacs window.
Debugging scripts is not nearly as comfortable as in the Windows or Macintosh environment, where the editor windows have buttons for running the script stepwise. Instead, debugging has to be done by issuing commands for setting breakpoints, etc., on the command line. Mathworks could make big improvements by adding, for example, a window with Step In/Over/Out buttons with a display showing the next command and offering the option of adding breakpoints.
In my opinion, it should be rather straightforward to implement this in Tcl/Tk with the script sending the specific command to the command line. An inspection window for variables would also be a neat feature, one that, to my knowledge, does not even exist on other platforms.
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems
Join editor Bill Childers and Bit9's Paul Riegle on April 27 at 12pm Central to learn how to keep your Linux systems secure.
Free to Linux Journal readers.Register Now!
- Cluetrain at Fifteen
- Embedding Python in Your C Programs
- Getting Good Vibrations with Linux
- New Products
- Memory Ordering in Modern Microprocessors, Part I
- [<Megashare>] Watch Mrs Brown's Boys Movie Online Full Movie HD 2014
- Customizing Vim
- Security Hardening with Ansible
- RSS Feeds
- Tech Tip: Really Simple HTTP Server with Python