Personal tools
You are here: Home Developer Infrastructure Teams Build and Release Setting up Mac OS X to use the Matlab Interface

Setting up Mac OS X to use the Matlab Interface

To use the Matlab Interface under Mac OS X requires some set up.

Under Mac OS X, the Matlab interface requires that the DYLD_LIBRARY_PATH environment variable be set to include the Matlab shared libraries.

For example, if you are running Mac OS X 10.7, your Matlab installation is at /Applications/, the DYLD_LIBRARY_PATH variable needs to be set to /Applications/

In addition, your path needs to include the directory that contains the "matlab" command.


Unfortunately, there are complications.

32-bit or 64-bit

The exact path depends on whether you are running a 32-bit Java Virtual Machine or a 64-bit virtual machine.  As of August, 2011, it seems that Mac OS X 10.5 may be running a 32-bit Java Virtual Machine and Mac OS X 10.6 and later is running a 64-bit virtual machine.  


To test, run java -version. 

bash-3.2$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

The above indicates that a 64-bit Java Virtual Machine is in use.

If the Matlab installation is at $MATLAB, then for 64-bit virtual machines, set the value of DYLD_LIBRARY_PATH to $MATLAB/bin/maci64.

If the Matlab installation is at $MATLAB, then for 64-bit virtual machines, set the value of DYLD_LIBRARY_PATH to $MATLAB/bin/maci.

Setting Environment Variables for Applications

Unfortunately, Mac OS X has a very arcane way of setting properties for applications that are started by clicking on an icon.

The preferred way is to use the "Property List Editor" application, see

Unfortunately, "Property List Editor" is part of XCode and XCode 4.x is not free and is a very large download.  If XCode is installed, then "Property List Editor" might be found in Macintosh HD/Developer/Applications/Utilities/Property List Editor.

An alternative to using "Property List Editor" is to create ~/.MacOSX/.environment.plist with a text editor such as TextEdit

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

No matter how ~/.MacOSX/.environment.plist is created, log out and log back in again to get the updated values.


Setting the Path

The Matlab actor looks for the "matlab" executable.  If the "matlab" executable cannot be found, the following error message appears:

ptolemy.kernel.util.IllegalActionException: : can't find Matlab engine.Try starting Matlab by hand as an application to verify that Matlab is set up properly and the license is correct. Under Windows, try running "matlab /regserver", the Matlab C API communicates with Matlab via COM, and apparently the COM interface is not automatically registered when Matlab is installed. Under Linux and other types of UNIX, csh must be installed in /bin/csh.
    at ptolemy.matlab.Expression.preinitialize(

Unfortunately, we can't use environment.plist to set the path for applications started by clicking on icon because we would end up overwriting the path set for other applications.

The trick is to create a symbolic link in /usr/bin to the matlab script.  To create this file requires becoming root usng the "sudo" command:

sudo ln -s /Applications/ /usr/bin/matlab
Document Actions