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 the Endianness of the Data.
This object supports C and C++ code generation.
To read data from a binary file:
Create a dsp.BinaryFileReader
object
and set the properties of the object.
Call step
to read the binary file.
Note:
Alternatively, instead of using the |
reader = dsp.BinaryFileReader
creates a
binary file reader object, reader
, using the default
properties.
reader = dsp.BinaryFileReader(fname)
sets
the Filename
property to fname
.
reader = dsp.BinaryFileReader(fname, Name, Value,
...)
with Filename
set to fname
,
and each property Name
set to the specified Value
.
Unspecified properties have default values.
Example:
reader = dsp.BinaryFileReader('myFilename.bin','SamplesPerFrame',1000,'NumChannels',2);
clone | Create copy of System object with same property values |
isdone | End-of-file status (logical) |
isLocked | Locked status for input attributes and nontunable properties |
readheader | Read file header |
release | Enable property values and input characteristics to change |
reset | Reset internal states of System object |
step | Read data from binary file |