Programming Previous page   Next Page

Using Low-Level File I/O Functions

MATLAB includes a set of low-level file I/O functions that are based on the I/O functions of the ANSI Standard C Library. If you know C, you are probably familiar with these routines. This section covers

The MATLAB file I/O functions use the same programming model as the C language routines. To read or write data, you perform these steps:

  1. Open the file, using fopen. fopen returns a file identifier that you use with all the other low-level file I/O routines.
  2. Operate on the file.
    1. Read binary data, using fread.
    2. Write binary data, using fwrite.
    3. Read text strings from a file line-by-line, using fgets/fgetl.
    4. Read formatted ASCII data, using fscanf.
    5. Write formatted ASCII data, using fprintf.
  3. Close the file, using fclose.

This section also describes how these functions affect the current position in the file where read or write operations happen and how you can change the position in the file.


Previous page  Using the MATLAB HDF Utility API Opening Files Next page

© 1994-2005 The MathWorks, Inc.