Steve Eddins retired from MathWorks in 2024 after 30 years of service. He can now be found at MATLAB Central and at Matrix Values, where he continues to write about MATLAB and related topics. His MathWorks career included image processing, toolbox development, MATLAB development and design, development team management, and MATLAB design standards. He wrote the Steve on Image Processing blog for 18 years and is a co-author of Digital Image Processing Using MATLAB.
An amateur musician and French horn enthusiast, Steve is a member of Concord Orchestra and Melrose Symphony Orchestra, as well as a member of the board of directors for Cormont Music and the Kendall Betts Horn Camp. He blogs about music and French horn at Horn Journey.
R2013a, the latest semi-annual MathWorks product release, just went live. One of the significant new capabilities in the MATLAB release is a new unit test framework (overview video, documentation). I am very happy to see this!
Long-time blog readers might be wondering, though, what about MATLAB xUnit? This is a unit test framework that I created and put on the File Exchange. I first wrote about it in this space in 2009. It is my second most popular File Exchange contribution (over 200 downloads in the last 30 days).
I learned to write unit tests when I came to MathWorks in 1993 as a new software developer. I've used several generations of test frameworks created for internal use here. Until recently, our internal testing machinery was tightly coupled to the entire system we used to build, test, and release our products, and so it was impractical to use it for small projects. This became an issue for me sometime around 2002-2003, as I was working on the first edition of Digital Image Processing Using MATLAB. As the "software guy" among the three coauthors, I was responsible for overseeing the MATLAB functions in the book, including making sure that everything was working OK. So I wrote a simple test harness that exercised the book's examples and some of the functions.
Later, the MATLAB R2008a release included the new generation of object-oriented language features. I was interested in learning more about it. Coincidentally, I had just read Kent Beck's Test-Driven Development, which included a case study on using test-driven development methods to create an xUnit-style test harness. I decided that would be an excellent project with which to learn about test-driven development as well as the R2008a MATLAB language changes. (With the wisdom of hindsight, I have to say here that I don't actually recommend learning test-driven development by using test-driven development to develop a test harness. It hurt my brain too much.)
Anyway, sometime in the spring on 2008 I had something pretty basic working. At about that time, Greg Wilson (original creator of Software Carpentry) visited MathWorks to give a talk about his edited book, Beautiful Code. I met Greg then, and we talked about the needs of MATLAB scientific users. Greg encouraged me to turn my fledgling tool into something real. He also invited me to write up something for the IEEE magazine, Computing in Science and Engineering. That became the article "Automated Software Testing for MATLAB", published in the November/December 2009 issue.
The MATLAB xUnit package raised the visibility of unit testing tools in MATLAB, and its popularity helped make the case for putting something like it in MATLAB. At the same time, our testing tools team was looking to modernize our testing infrastructure. They wanted to take advantage of the latest test framework design principles, and they wanted to decouple the testing machinery from the rest of our complex systems for building and releasing products. So an idea was born: let's make a test framework that can stand on its own, that can test our own software, that can test customer code, and that we can ship in MATLAB!
Someone asked me just this week about enhancing MATLAB xUnit to provide for setup and teardown methods that get executed just once for all the methods in a test file, instead of being executed once for every individual test method. MATLAB xUnit does not have this capability, but the new unit test framework in R2013a does. A class-level setup method is identified by using the TestClassSetup method attribute, like this:
There are lots of new capabilities in this framework. A little birdie told me that more information about matlab.unittest may appear pretty soon in Loren's blog. For now, though, I'd like to point you to the overview video and to the documentation.
That brings me back to MATLAB xUnit and its fate. Well, this little package is entering its "retirement phase." I imagine it will remain on the File Exchange for quite a while because it can take a long time for the user community to adopt a new release, and also because there's a lot of customer-written code out there that uses it. However, I do not plan to work on it anymore. Our testing tools team is an excellent group of engineers, and they can move matlab.unittest forward better and faster than I could ever do with my little side project.
I recently installed Matlab R2013a and it is working fine, however the only way I can start it is by running /usr/local/MATLAB/R2013a/bin/matlab in the terminal. If I type in matlab it says command not found, and I can't seem to get an icon in the side-bar launcher. How can I make it so I can run from the command matlab or from a launcher?
Edit: I have created a link so I can launch it by typing matlab in the terminal. I still can't get the unity icon launcher working though. I managed to create an icon via a matlab.desktop file in /usr/share/applications. When I click it, it launches Matlab, but after the initial loading screen Matlab shuts down instead of launching the application. It works through the terminal though. My matlab.desktop file is:
To my experience by far, the far simplest solution I have figured out yet is to simply install "matlab-support" through apt-get. It solves not only this issue but others as well. Just pop open a terminal and type
That should launch matlab. If it works, then right-click on the matlab icon in the unit launcher and then select 'lock to launcher'. If it doesn't work, then check that the file has execute permissions, and that your sym link is working.
A large amount of software available to managed Engineering Linux computers is available via environment modules. These modules allow Engineering IT to distribute large software packages without having to install the software on individual machines. They also allow Engineering Linux users access to multiple versions of popular software, such as Mathematica or MATLAB.
While you may see a software module that you may want to use listed as available, some are only available to specific research groups or instructional labs due to difference in licensing or licenses purchased by individual research groups. For instance, in the above list you see two versions of the Abaqus module. The module called "abaqus" uses the general instructional license, while "abaqus-research" uses the research license.
That's all it takes to load a module and you may immediately begin using the software. Note that you do not need to use the full module name of software/version that is displayed through module avail unless you are trying to load a specific version of the software. In the example above, 'module load mathematica' and 'module load mathematica/8.0' would mean the same thing.
Although it is not necessary to unload modules when you are no longer using the software, by doing so you can switch between multiple versions of software while keeping your environment clean and consistent.
When you issue a 'module load matlab' command the version of MATLAB that will load is indicated by the '(default)' descriptor next to it. In this case R2011a will be loaded. If you wish to use another available version, you must use the full module name. If you were to load R2013a you would use 'module load matlab/R2013a'.
If you currently have one version of a module loaded and wish to use another, you may use the shorthand 'module switch' command rather than unloading the old version's module and loading loading the new one. The syntax for this is 'module switch currentmodule newmodule'.
Some packages are installed on your system directly without the need to use modules. This includes most of the dependencies that the software modules may have, or smaller or more common packages available in the yum repositories, such as gcc and make.
If a software package you would like to use for your research is not available on a cluster, you can request it to be installed. The software requests are evaluated by the HPC staff on a case-by-case basis. Before you send in a software request, please go through the information below.
MATLAB is a high-level language and interactive environment developed by Mathworks. It is widely used in science and engineering across industry and academia. Users need to provide their own license file, which should have a .lic extension and be located under /home/$USER/.matlab/R2020a_licenses.
Matlab is installed on most of the HPC clusters. It is, however, license software, which means that it is only availabe to users or user groups who have access to a license, purchased either individually or by the users' institution.
If you do have lots of similar jobs, we recommend you to compile your Mablab scripts using the Matlab compiler, and the jobs using the compiled executable will not take license seats, If you need help in this regard, please contact us at sys-...@loni.org.
For LONI users who want to use Matlab on QB2, you need to provide your own license file. The license file should have a .lic extension and be located under the "/home/$USER/.matlab/R_licenses" directory. For example, in order to user Matlab R2013a, you need to create the directory ".matlab/R2013a_licenses" under your home directory and put the license file there.
b1e95dc632