FUNCTION REFERENCE

fwrite

Write binary data to a file.

Write binary data to a file.

Syntax

count = fwrite(fid, A)

Syntax

count = fwrite(fid, A, precision)

Syntax

count = fwrite(fid, A, precision, 0, machinefmt)

precision is 'uint8' (default), 'int8', 'uint16', 'int16', 'uint32', 'int32',

'uint64', 'int64', 'single', 'double' or 'char'. Integers round to the nearest

value and saturate. machinefmt is 'l' or 'b'; without it the byte order given

to fopen is used (little endian by default). Characters are written

as their character codes. Returns the number of elements written; a file

opened for reading only writes nothing and returns 0.

Example

fid = fopen('b.bin', 'w'); fwrite(fid, [1 2 3 255])   % 4

Differences from MATLAB: a skip value other than 0 and the N*type form are not supported.

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