|MATLAB Function Reference|
Write binary data to a file
count = fwrite(fid,A,precision)
writes the elements of matrix
A to the specified file, translating MATLAB values to the specified
precision. The data is written to the file in column order, and a
count is kept of the number of elements written successfully.
fid is an integer file identifier obtained from
1 for standard output or
2 for standard error.
precision controls the form and size of the result. See
fread for a list of allowed precisions. For
fwrite sets all bits in
A when the value is out-of-range.
count = fwrite(fid,A, includes an optional
skip argument that specifies the number of bytes to skip before each
precision value is written. With the
skip argument present,
fwrite skips and writes one value, skips and writes another value, etc. until all of
A is written. If
precision is a bit format like
skip is specified in bits. This is useful for inserting data into noncontiguous fields in fixed-length records.
creates a 100-byte binary file, containing the 25 elements of the 5-by-5 magic square, stored as 4-byte integers.