External Interfaces |
Exporting Data from MATLAB
There are several methods for getting MATLAB data back to the outside world:
For small matrices, use the diary
command to create a diary file and display the variables, echoing them into this file. You can use your text editor to manipulate the diary file at a later time. The output of diary
includes the MATLAB commands used during the session, which is useful for inclusion into documents and reports.
Save the data in ASCII form using the save
command with the -ascii
option. For example,
creates an ASCII file called temp.dat
containing
1.3889088e-001 2.7218792e-001 4.4509643e-001 2.0276522e-001 1.9881427e-001 9.3181458e-001 1.9872174e-001 1.5273927e-002 4.6599434e-001 6.0379248e-001 7.4678568e-001 4.1864947e-001
The -ascii
option supports two-dimensional double and character arrays only. Multidimensional arrays, cell arrays, and structures are not supported.
See the save
function reference page for more information.
Write the data in a special format using fopen
, fwrite
, and the other low-level I/O functions. This method is useful for writing data files in the file formats required by other applications.
You can develop a MEX-file to write the data. This is the method of choice if subroutines are already available for writing data files in the form needed by other applications. See the section, Introducing MEX-Files, for more information.
You can write out the data as a MAT-file using the save
command. You can then write a program in C or Fortran to translate the MAT-file into your own special format. See the section, Reading and Writing MAT-Files, for more information.
Importing Data to MATLAB | Exchanging Data Files Between Platforms |
© 1994-2005 The MathWorks, Inc.