Development Environment    

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, therefore, you are probably familiar with these routines.

For example, 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.


  Getting More Information About HDF Opening Files