RE: [S] Importing Matlab Files

Traub, Richard J (Richard.Traub@pnl.gov)
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
Matlab.

Hope this helps.

Rick Traub
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news