fclose

Closes a file opened by fopen(). Requires the fileID returned by fopen as an argument.

Syntax

R = fclose(fileID)

Inputs

fileID
The fileID returned by an earlier fopen command.
Type: double | integer

Outputs

R
A return code: 0 if the close was successful, -1 on an error.
Type: double | integer

Example

Simple fclose example:

fileID = fopen('c:\tests\test1.txt')
fclose(fileID)
fileID = 3
ans = 0

Comments

Returns 0 if successful -1 if not.