The Advanced Photon Source
a U.S. Department of Energy Office of Science User Facility

Guide to Installing SDDS support for Matlab

Author: R. Soliday

If you have problems please email me at

Step 1: Linux
Download or build the SDDS Java Binary (JAR) file.
Step 1: Windows
Download the Java SDDS Binaries or build the the SDDS Java Binary (JAR) file.
Step 2: Linux
Edit /usr/local/matlab/toolbox/local/classpath.txt (your location may be different) and add a link to SDDS.jar.
Step 2: Windows
Edit C:\MATLAB6p1\toolbox\local\classpath.txt (your location may be different) and add a link to c:/Program Files/APS/Java SDDS/SDDS.jar
Step 3
If your Matlab version is older than version 13 you will have to install the Java Runtime Environment version 1.3.1. The newer versions will not work with Matlab and the version that comes with Matlab is too old to work with the Java SDDS library. Once installed you will have to set the environment variable MATLAB_JAVA to the directory of the JRE.
Step 4
Download and unpack the SDDS Matlab M-Files. These files can be used by Matlab if they are in the current working directory or if they are added to Matlab's path.
Step 5
You can now load sdds files into a Matlab structure. The structure looks like:


sdds.parameter.[parameter name].type

sdds.column.[column name].type

sdds.array.[array name].dimensions

The commands for loading and saving SDDS files from Matlab are:

sdds = sddsload('inputFile.sdds') % Load inputFile.sdds
sddssave(sdds)                    % Save to sdds.filename
sddssave(sdds, 'outputFile.sdds') % Save to outputFile.sdds

Note: Not all fields are required to save an SDDS file.
Answers to common questions
The values for columns are returned asjava.lang.struct objects. 
How do I convert these into MATLAB vectors?

Using the SDDSUtil.castArrayAsDouble command. Here is an example:

sdds = sddsload('/tmp/junk')
sdds.column.[column name].page1 = 
  SDDSUtil.castArrayAsDouble(sdds.column.[column name].page1, 
                             SDDSUtil.identifyType(sdds.column.[column name].type))

I am getting the error message java.lang.OutOfMemoryError what do I do?

When Matlab starts the java interpreter it starts it with a maximum 
Java memory heap size which is often too small. On Solaris all I have 
to do is start Matlab from a directory that contains a file called 
java.opts. This file has one line:

This tells matlab to start the java interpreter with 256 MBs as the 
maximum Java memory heap size.

I think on Windows this file would go in the directory where the 
Matlab binary is.