fclose - Close one or all open files - MATLAB (original) (raw)
Main Content
Close one or all open files
Syntax
Description
fclose('all')
closes all open files.
status = fclose(___)
returns astatus
of 0
when the close operation is successful. Otherwise, it returns -1
. You can use this syntax with any of the input arguments of the previous syntaxes.
Examples
Open the badpoem.txt
file, read the first line, and then close the file.
Use fopen
to open the file. This function assigns a unique file id to use for reading and writing to the file.
fid = fopen('badpoem.txt')
Read the first line from the file using fgetl
.
ans = 'Oranges and lemons,'
Close the file.
Input Arguments
File identifier of an open file, specified as an integer. Before closing a file with fclose
, you must use fopen to open the file and obtain its identifier fileID
.
Data Types: double
Extended Capabilities
Usage notes and limitations:
- The
fclose('all')
syntax is not supported in thread-based environments.
Version History
Introduced before R2006a
You can read data from primary online sources by performing low-level file read operations over an internet URL.
This function supports thread-based environments.