fwrite

Write data in binary form to the file specified by the file descriptor fid.

Syntax

  • count = fwrite(fid, data)

  • count = fwrite(fid, data, precision)

  • count = fwrite(fid, data, precision, skip)

  • count = fwrite(fid, data, precision, skip, arch)

  • count = fwrite(fid, data, precision, arch)

Input argument

  • fid - a file descriptor

  • data - data to write

  • precision - class of values to read

  • skip - number of bytes to skip

  • arch - a string specifying the data format for the file.

Output argument

  • count - -1 or number of elements written

Description

Write data in binary form to the file specified by the file descriptor fid.

characters encoding uses fopen parameter.

supported architecture:

native , n: format of the current machine.

ieee-be, b: IEEE big endian.

ieee-le, l: IEEE little endian.

Example

A = rand(3,1)

fileID = fopen([tempdir(), 'doubledata.bin'],'w');
fwrite(fileID, A,'double');
fclose(fileID);

fileID = fopen([tempdir(), 'doubledata.bin'],'r');
R = fread(fileID, 'double')
fclose(fileID);

See also

fopen, fclose, fread.

History

VersionDescription

1.0.0

initial version

Author

Allan CORNET

Last updated