• The most straightforward way is to install the MATLAB interface to Madagascar. When installing Madagascar, run
./configure API=matlab

The configure script will try to find and test matlab and mex executibles on your system. If they are not in your PATH, you can specify them with

./configure API=matlab MATLAB=/path/to/matlab MEX=/path/to/mex

Install Madagascar as usual, set MATLAB path to \$RSFROOT/lib, and you will able to read and write RSF files from MATLAB using rsf_read, rsf_write, and other functions from the Madagascar interface.

• Alternatively, you can try reading binary data using MATLAB functions, as in the following example

% get in=, n1=, and n2= parameters from file.rsf
[stat,in] = unix(‘sfget in parform=n < file.rsf’)
in = strtrim(in)
[stat,n1] = unix(‘sfget n1 parform=n < file.rsf’)
n1 = str2num(n1)
[stat,n2] = unix(‘sfget n2 parform=n < file.rsf’)
n2 = str2num(n2)
% read binary data
fid = fopen(in,‘rb’)
data = reshape(data,n1,n2);