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. To view the alphabetical list of MATLAB binary data export functions, see Table 6-6.

Table 6-5: Binary Data Formats and MATLAB Import Functions

Data Format
File Extension
Function
Audio files
.au
.wav
auread (on Sun systems)
wavread (on Microsoft Windows systems)
Audio-video Interleaved (AVI)
.avi
aviread
Band-interleaved data
No standard file extension
multibandread
Common Data Format (HDF)
.cdf
cdfread
Hierarchical Data Format (HDF)
.hdf
imread
Use imread only for HDF raster image files. For all other HDF files, see Importing HDF Data for complete information.
Image files
.bmp
.cur
.gif
.hdf
.ico
.jpg (.jpeg)
.pbm
.pcx
.pgm
.png
.pnm
.ppm
.ras
.tif (.tiff)
.xwd

imread
MATLAB proprietary format (MAT-files)
.mat
load
See Loading a Saved Workspace and Importing Data for more information.
Spreadsheets (Excel or Lotus 123)
.xls
.wk1

xlsread
Table 6-6: Binary Data Import Functions

Function
File Extension
Data Format
auread
.au
Import sound data in Sun Microsystems format.
aviread
.avi
Import audio-visual data in AVI format.
cdfread
.cdf
Import Common Data Format (CDF) data.
hdf
.hdf
Import data in Hierarchical Data Format (HDF). For HDF image file formats, use imread. For all other HDF files, see Importing HDF Data for complete information.
imread
.bmp
.cur
.gif
.hdf
.ico
.jpg (.jpeg)
.pbm
.pcx
.pgm
.png
.pnm
.ppm
.ras
.tif (.tiff)
.xwd

Import images in many formats.
load
.mat
Import MATLAB workspace variables in MAT-files format.
multibandread
No standard file extension
Import three-dimensional, band-interleaved data.
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