FUNCTION REFERENCE

fscanf

Read formatted data from a file.

Read formatted data from a file.

Syntax

A = fscanf(fid, format)

Syntax

A = fscanf(fid, format, sizeA)

Syntax

[A, count] = fscanf(fid, format, sizeA)

format may use %d %i %u %f %e %g %s %c, widths and %* to skip. The format is reused

until the data ends or does not match; a zero width such as %0d reads nothing.

%c also reads white space and line breaks. The result is a column of numbers; with

only %s and %c it is a character row. sizeA is Inf, N or [m n].

Example

A = fscanf(fid, '%d', [3 Inf])   % [1 4; 2 5; 3 6] for the file '1 2 3' and '4 5 6'

Differences from MATLAB: other conversions such as %x and %[ are not supported.

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