FUNCTION REFERENCE

ferror

File I/O error status for an open file identifier.

File I/O error status for an open file identifier.

Syntax

msg = ferror(fid); [msg, errnum] = ferror(fid); ferror(fid, 'clear')

Returns the last error message and numeric error code for an open file identifier (empty and 0 when none). Passing 'clear' resets the stored error status.

Example

fid = fopen("f.txt", "w"); [msg, errnum] = ferror(fid); fclose(fid)

Differences from MATLAB: Standard identifiers 0, 1, 2 are rejected; only file identifiers from fopen are accepted.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.