dsp.BinaryFileWriter
Write data to binary files
Description
The dsp.BinaryFileWriter
System object™ writes multichannel signal data to a binary file. If the header is not empty,
then the header precedes the signal data. The object specifies the file name and the structure
of the header. The first time you write to the file, the object writes the header, followed by
the data. On subsequent calls, the object writes the remaining data. If the header is empty,
then no header is written.
The object can write floating-point data and integer data. To write character data and
fixed-point data, see Write and Read Character Data and Write and Read Fixed-Point Data. The input data can be real or complex. When the data is complex,
the object writes the data as interleaved real and imaginary components. For an example, see
Write and Read Fixed-Point Data. By
default, the writer uses the endianness of the host machine. To change the endianness, you can
use the swapbytes
function. For an example, see Change Endianness of Data Before Writing.
To write data to a binary file:
Create the
dsp.BinaryFileWriter
object and set its properties.Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
Creation
Syntax
Description
creates a
binary file writer object, writer
= dsp.BinaryFileWriterwriter
, using the default
properties.
sets the writer
= dsp.BinaryFileWriter(fname
)Filename
property to fname
.
with writer
= dsp.BinaryFileWriter(fname
,Name,Value
)Filename
set to fname
and each property
Name
set to the specified Value
. Unspecified
properties have default values.
Example: writer =
dsp.BinaryFileWriter('myFilename.bin','HeaderStructure',struct('field1',1:10,'field2',single(1)));
Properties
Usage
Syntax
Description
writer(
writes data to the binary file
in a row-major format. Each call to the algorithm writes the elements of
data
)data
at the end of the file. At the first call to the algorithm,
the object writes the header first, followed by the data. If the header is empty, then no
header is written.
The input data can be real or complex. For complex data, real and imaginary parts are
interleaved. For example, if the data equals [1 2; 3 4]+1j*[5 6; 7 8]
,
then the object writes the elements as 1 5 2 6 3 7 4 8
.
Input Arguments
Object Functions
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named obj
, use
this syntax:
release(obj)
Examples
Extended Capabilities
Version History
Introduced in R2016b