Matlab Integration and SciPy

This post contains informal notes collected while researching options and techniques for using Matlab to do complex numerical programming work while integrating with existing code bases. Also includes notes and links on alternatives. I used a trial version of MATLAB R2012B to build a proof-of-concept against an existing Java based project.

Using Java from within Matlab

The java integration with Matlab is straightforward and works well.  (The same seems to be true for .NET integration, although I didn’t test it.)   No additional toolboxes or addons are required, beyond the core Matlab product, in order to call java classes from within Matlab.

However, there is one significant caveat; the java classpath of any custom code must share the classpath with matlab, and matlab includes a number of well-known libraries. My proof-of-concept project also used a lot of libraries and so there were a number of conflicts that made it difficult to reuse my code in Matlab directly. I almost got it to work eventually and probably could’ve if I continued, but I ended up taking a different approach using a remote network interface rather than direct Java library calls. The network based approach is much more flexible and doesn’t suffer from the classpath conflict issues

In my proof-of-concept I published an RMI service as an interface in to my existing code base (which required minimal amount of code & setup since I was already using Spring Framework). I then built a small JAR library for use by Matlab that provided an RMI client proxy to the remote services. I used RMI, but could easily have used any other remoting protocol as well, such as Spring’s HTTP remoting. This setup worked well, and is flexible because it provides a dedicated area where matlab specific conversions and handling can be done with impact on existing code. It is also negated issues with classpath conflicts. Yet another benefit was that the Matlab client could be running on a different machine than the server code base.

Using .NET from within Matlab

Similar to Java integration, no additional toolboxes or addons are required in order to call .NET assemblies from within Matlab.

Calling Matlab from Java/.NET

Calling in to matlab from Java/.NET requires addons. The official approach to is to purchase the matlab compiler and then a standalone toolbox specific to each platform. This combination lets you compile standalone executables (and libraries?).


I’m not sure what the rules are around publishing pricing information, but suffice to say, the official Matlab approach requires a relatively expensive initial investment.  Required components include:

  • Matlab Core
  • Matlab Compiler
  • Matlab Builder for Deployment  (per platform)

The initial pricing I received would’ve required >$10k to get started. There are no runtime distribution costs though.

Alternative Unofficial Approaches

Additional Research

The remaining part of this post is primarily a collection of links and notes I generated while researching.

I don’t have much experience using external math engines in recent projects, however, based on what I’ve researched, I would not lean towards using Matlab for my own projects these days. It might be different if I had extensive knowledge of Matlab already, or lots of code that depended on it.

Matlab Alternatives


Matlab to NumPy

NumPy/SciPy Development

Dedicated SciPy IDEs

Generic Python IDEs


Misc Links & Articles

Matlab vs PySci


Mathematica vs Matlab vs Sage vs Octave

Python & Qt, PySide/PyQt

Matlab & Python

Matlab, Misc

category: misc
<< prev
Flight Viz w/ Google Earth
^ up ^
Blog Index
next >>
Dynamic Loading w/ Dygraphs