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 soliday@aps.anl.gov

Step 1:
Download or build the SDDS Java Binary (JAR) file. This is the SDDS.jar file that is included with the SDDS Java Binaries. You can also get it directly from https://ops.aps.anl.gov/downloads/SDDS.jar
Step 2
Download and unpack the SDDS Matlab Release package. This unpacks to epics/extensions/src/SDDS/matlab/
Step 3
Your Matlab scripts should include:
javaaddpath('SDDS.jar', '-end')
import SDDS.java.SDDS.*
path(path,'epics/extensions/src/SDDS/matlab')
You will have to add the full pathname for both SDDS.jar and the directory containing the SDDS Matlab Release files.
Step 4
You can now load sdds files into a Matlab structure. The structure looks like:
sdds.filename
sdds.ascii
sdds.pages
sdds.parameter_names
sdds.array_names
sdds.column_names

sdds.description.contents
                .text

sdds.parameter.[parameter name].type
                               .units
                               .symbol
                               .format_string
                               .description
                               .data

sdds.column.[column name].type
                         .units
                         .symbol
                         .format_string
                         .description
                         .page[number]

sdds.array.[array name].dimensions
                       .type
                       .units
                       .symbol
                       .format_string
                       .group_name
                       .description
                       .size_page[number]
                       .page[number]
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:
import SDDS.java.SDDS.*
sdds = sddsload('/tmp/junk')
sdds.column.[column name].page1 = 
  SDDSUtil.castArrayAsDouble(sdds.column.[column name].page1, 
                             SDDSUtil.identifyType(sdds.column.[column name].type))