Development Environment | ![]() ![]() |
Using Import Functions with Binary Data
To import binary data from the command line or in an M-file, you must use one of the MATLAB import functions. Your choice of function depends on how the data in the text file is formatted.
To find the function designed to work with a particular binary data format, scan the data formats listed in Table 6-5. The table lists the binary formats and the MATLAB high-level functions you use to import them, along with pointers to additional information.
Table 6-5: Binary Data Formats and MATLAB Import FunctionsData Format |
File Extension |
Description |
Audio files |
.au |
Use the auread function to import audio files on Sun Microsystems platforms and the wavread function to import audio files on Microsoft Windows systems. |
Audio-video Interleaved (AVI) |
.avi |
Use the aviread function to import Audio-video Interleaved (AVI) files. |
Hierarchical Data Format (HDF) |
.hdf |
For HDF image files, use imread . For all other HDF files, see Working with HDF Data for complete information. |
Image files |
.jpeg .tiff .bmp |
Use the imread function to import image data in many different formats. See Reading, Writing, and Querying Graphics Image Files for more information. |
MATLAB proprietary format (MAT-files) |
.mat |
Use the load command to import data in MATLAB proprietary format. See Loading a Saved Workspace for more information. |
Spreadsheets |
.xls |
Use xlsread to import Excel spreadsheet data or wk1read to import Lotus 123 data. |
To view the alphabetical list of MATLAB binary data export functions, see Table 6-6.
If MATLAB does not support a high-level function that works with a data format, you can use the MATLAB low-level file I/O functions, if you know how the binary data is formatted in the file. See Using Low-Level File I/O Functions for more information.
Table 6-6: Binary Data Import FunctionsFunction |
File Extension |
Data Format |
auread |
.au |
Import sound data in Sun Microsystems format. |
aviread |
.avi |
Import audio-visual data in AVI format. |
hdf |
.hdf |
Import data in Hierarchical Data Format (HDF). For HDF image file formats, use imread . For all other HDF files, see Working with HDF Data for complete information. |
imread |
.jpeg , .tiff , .bmp , .png , .hdf , .pcx , .xwd, .gif |
Import images in many formats. |
load |
.mat |
Import MATLAB workspace variables in MAT-files format. |
wavread |
.wav |
Import sound data in Microsoft Windows format. |
wk1read |
.wk1 |
Import data in Lotus 123 spreadsheet format. |
xlsread |
.xls |
Import data in Microsoft Excel spreadsheet format. |
![]() | Using the Import Wizard with Binary Data Files | Exporting Binary Data | ![]() |