RE: [S] Importing Matlab Files

Traub, Richard J (
Fri, 24 Jul 1998 08:07:03 -0700

Alice Ling asks:

Has anyone had
any success and have any advice for importing Matlab files?

To a limited extent I have imported Matlab files into S-Plus.

What I have found is that by default Matlab prints to file the transpose of
whatever matrix you want.

What works for me is to use the fprintf() command to print from Matlab. This
will give you a file that can be read into S-plus using scan().

For example in Matlab do somethine like the following:

fid = fopen(fileName,'w') ;
fprintf(fid,'%6.2f %12.8e %12.8e %12.8e %12.8e %12.8e %12.8e %12.8e %12.8e
%12.8e %12.8e %12.8e %12.8e\n',printMatrix) ;
fclose(fid) ;

In the above, "printMatrix" is a matrix that I built from data generated in

Hope this helps.

Rick Traub
This message was distributed by To unsubscribe
send e-mail to with the BODY of the
message: unsubscribe s-news