dsp.BinaryFileReader
Read data from binary file
Description
The dsp.BinaryFileReader
System object™ reads multichannel signal data from a binary file. If the header is not empty,
then the header precedes the signal data. The System object specifies the prototype of the header, and the type, size, and complexity of the
data. The first time you read the file, the reader reads the header, followed by the data. On
subsequent calls, the reader reads the remaining data. Once the end of file is reached, the
reader returns zeros of the specified data type, size, and complexity. The reader can read
signal data from a binary file that is not created by the dsp.BinaryFileWriter
System object.
The object accepts floating-point data or integer data. To read character data and
fixed-point data, see the Write and Read Character Data and Write and Read Fixed-Point Data examples. The input data can be real or complex. When the data is
complex, the object reads the data as interleaved real and imaginary components. For an
example, see Read Complex Data.
The reader assumes the default endianness of the host machine. To change the endianness, you
can use the swapbytes
function. For an example, see Change Endianness of Data.
To read data from a binary file:
Create the
dsp.BinaryFileReader
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 reader object, reader
= dsp.BinaryFileReaderreader
, using the default
properties.
sets the reader
= dsp.BinaryFileReader(fname
)Filename
property to fname
.
reader = dsp.BinaryFileReader(
with fname
,Name,Value
)Filename
set to fname
, and each specified
property set to the specified value. Unspecified properties have default values.
Example: reader =
dsp.BinaryFileReader('myFilename.bin','SamplesPerFrame',1000,'NumChannels',2);
Properties
Usage
Syntax
Description
Output 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