Close a file

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.




fclose(n) closes the file specified by the file descriptor n.

The file must have been opened with fopen. The call to fopen yields the file descriptor n representing the file.

Only a limited number of file descriptors is available. The user should use fclose to close a file which is no longer needed because this releases the file descriptor. The exact number of file descriptors available depends on the used operating system.


Example 1

We open a file test for writing. This yields the file descriptor n:

fid := fopen(TempFile, Write, Text):
file := fname(fid):
n := fopen(file, Write):

We close the file:

delete n:



A file descriptor returned by fopen: a positive integer

Return Values

Void object of type DOM_NULL.