Issue No.03 - May/June (2012 vol.14)
Published by the IEEE Computer Society
DOI Bookmark: http://doi.ieeecomputersociety.org/10.1109/MCSE.2012.58
<p>The author reviews a book dealing with the intricacies associated with Matlab (a popular platform for numerical computing) and its Java interface.</p>
This book deals with the intricacies associated with Matlab (a popular platform for numerical computing) and its Java interface. Specifically, it introduces and describes a myriad of strategies that will enable a Matlab user to understand—and become a productive user of—this interface. Some of these strategies involve playing with the interface as it is, while others involve modifying the interface to suit the user's needs. As the book's title indicates, these strategies were previously undocumented. Indeed, the book contains countless examples that would otherwise be hidden from a Matlab user, which makes this an important volume.
Secrets and Features
The book opens with a preface that, among other things, warns the reader that the book relies on undocumented functionality that isn't officially supported by Mathworks (the developers of Matlab). It warns the reader not to use any undocumented feature or function unless the reader is fully aware of the possible consequences. For example, unsupported features might not work in future Matlab versions, they might behave differently on different platforms, and they might have undesirable side effects, even causing Matlab to crash or freeze.
The book claims that it's intended for Matlab programmers and users, and that no Java knowledge is assumed. It also claims that Java-savvy programmers will find it easier to use and extend some of the more advanced topics. The text provides an appendix dedicated to introducing Java concepts to the novice, which I found useful. I do believe a novice would probably need more, however, than is provided in the appendix.
The opening chapter starts with basics, such as ensuring that Java is supported in the specific Matlab platform. It even shows the specific commands to type to do that. It then goes on to discuss Java objects, safe Java programming, and compatibility issues.
Chapter 2 introduces non-GUI Java libraries used in Matlab and provides detailed examples of how to build Java functionality to increase Matlab productivity. In chapter 3, the author guides programmers to access almost all of the modern GUI facilities that Java makes available, and upon which Matlab is based. Matlab does this through the Java Swing class, which is its primary GUI application toolkit.
Next, in chapter 4, the author goes into Java-based customizable user-interface functions that MathWorks calls user-interface tools or Uitools. These tools deal with customizing tables, trees, tabs, toolbars, and menus.
Chapter 5 involves Java classes and built-in Matlab applications or widgets. In chapter 6, the book delves into Matlab's controls, such as the push button, toggle button, checkbox, slider, and frame.
The following chapter deals with the Java frame, including details of how Matlab figures make use of Java Swing objects. This includes the Swing JFrame's properties and methods, components, and containers. Chapter 8 discusses how Matlab's desktop or integrated development environment (IDE) is rich with tricks regarding its layout, the clients (command window, workspace, and so on), toolbars, window colors, editor, and keyboard responses in the editor.
After the first eight chapters, the reader should understand how to use Java within Matlab. Chapter 9, however, concentrates on how to access Matlab from within Java. Most of this chapter concentrates on the Java Remote Method Invocation (RMI) for connection and the Java-Matlab Interface (JMI) for functionality. It's apparent that this chapter fills a gap—Matlab can easily call Java, but the reverse isn't simple. The Java Native Interface (JNI) is used to connect Java with Matlab, and the author provides example code that can be used to test this capability. The process of connecting Java to Matlab via JNI involves writing a C code using various libraries and linking the code with Matlab's static libraries while creating a dynamic library. This is then declared within the Java code to load the dynamic library to be able to access its internal functions within Java. Additionally, the author mentions that Matlab clones that have been written in Java can be integrated in a Java application, but they're significantly inferior to Matlab. These clones are JMathLib, ARRAY4j, and jMatlab; however, no mention is made of the highly popular Octave, also a Matlab clone (see www.gnu.org/software/octave),which runs most Matlab code written by physicists and engineers. It probably isn't mentioned because Octave is written in C++, not Java.
Finally, chapter 10 attempts to tie together many of the capabilities and features described throughout the text. This chapter describes a utility, UISplitPane, which is designed to make use of those features. The code listing for this application is provided, as well as a description of how to download the code online. In fact, by executing a search under the author's name, much of the code contributed in this text can be freely accessed from Matlab's exchange website ( www.mathworks.com/matlabcentral/fileexchange).
It's important to mention that in every instance where the author demonstrates and discusses a trick, or details an example snippet, he also provides a link associated with the specific code. The author does this in a consistent and complete manner, which is quite helpful. All of the specific links and sources are given either as a footnote or in a list of references provided at the end of each chapter. However, although the codes are all available online with references provided to the relevant links, it would have been nice if a CD/DVD with all of the code had also been included with the book.
Who Will This Help?
While the author doesn't state the intended audience, this text will be most appreciated by people who are curious about many Matlab functions—how they operate, how they're interfaced, and the role Java plays in carrying this out. The book involves many technical details, but the ideas and concepts are clearly communicated. Moreover, a reader will quickly realize that the author is a seasoned veteran in Java programming, and a novice will certainly benefit from such expertise.
This book is probably too technical to be suitable as a textbook for most courses, although it might be appropriate for a Matlab-based computer engineering class where the goal is more than mere computation. For me, this book has certainly become an important reference to have on the bookshelf. In the words of the author, "This book shows the readers how to use and discover the described components, using nothing but Matlab itself as a discovery tool" (p. xix).
For readers who wish to enhance their expertise in numerical solutions of problems associated with physics, engineering, and mathematics, this might not be the text for you. The book is geared toward people who have an innate desire to change the way Matlab interfaces with Java, and to understand the details associated with the operating environment. I found that the Java procedures are quite interesting and challenging at the same time.
The writing style of this text is standard, and it's easily readable. Most chapters are characterized by some introductory comments, then moving on to the technical details. The chapter arrangement appears to be logical and the appendices help the reader to learn, or become acquainted with, Java. To me, the book is quite demanding to read, and it would take a great deal of time to master all of its content. Nevertheless, it's a valuable source of information and I imagine it will remain so for years to come. Thanks to this book, the word "undocumented" no longer describes Matlab's interface.
Javier E. Hasbun is a professor of physics at the University of West Georgia. His research focuses on theoretical solid-state physics, especially semiconducting alloy systems. Hasbun has a PhD in condensed matter physics from the University of New York at Albany. He's the author of Classical Mechanics with Matlab Applications and a coauthor of A First Course in Computational Physics. Contact him at email@example.com.