Read binblock data from instrument
A = binblockread(obj)
A = binblockread(obj,'
[A,count] = binblockread(...)
[A,count,msg] = binblockread(...)
An interface object.
The number of bits read for each value, and the interpretation of the bits as character, integer, or floating-point values.
Binblock data returned from the instrument.
The number of values read.
A message indicating if the read operation was unsuccessful.
A = binblockread(obj) reads binary-block
(binblock) data from the instrument connected to
obj and returns
the values to
A. The binblock format is described in the
A = binblockread(obj,'
reads binblock data translating the MATLAB® values to the precision specified by
precision. By default the
precision is used and numeric values are returned in double-precision
arrays. Refer to the
fread function for a list of
[A,count] = binblockread(...) returns the
number of values read to
[A,count,msg] = binblockread(...) returns
a warning message to
msg if the read operation did not complete
Create the GPIB object
g associated with a National
Instruments® GPIB controller with board index 0, and a Tektronix® TDS 210 oscilloscope with primary address 2.
g = gpib('ni',0,2); g.InputBufferSize = 3000;
g to the instrument, and write string commands that
configure the scope to transfer binary waveform data from memory location A.
fopen(g) fprintf(g,'DATA:DESTINATION REFA'); fprintf(g,'DATA:ENCDG SRPbinary'); fprintf(g,'DATA:WIDTH 1'); fprintf(g,'DATA:START 1');
CURVE? command, which prepares the scope to transfer
data, and read the data using the binblock format.
fprintf(g,'CURVE?') data = binblockread(g);
If the scope sends a terminating character after the binblock,
binblockread does not read the terminating character. Read it
fread. In this example,
count is the
number of bytes of the terminating character and can be
if g.BytesAvailable == count fread(g,count,'uint8'); end
Before you can read data from the instrument, it must be connected to
obj with the
fopen function. A connected
interface object has a
Status property value of
open. An error is returned if you attempt to perform a read
obj is not connected to the instrument.
binblockread blocks the MATLAB Command Window until one of the following occurs:
The data is completely read.
The time specified by the
msg is not included as an output argument and the read
operation was not successful, then a warning message is returned to the command
Each time binblockread is issued, the
ValuesReceived property value is increased by the number of
Some instruments may send a terminating character after the binblock.
binblockread will not read the terminating character. You can
read the terminating character with the
fread function. Additionally,
obj is a GPIB, VISA-GPIB, VISA-VXI, VISA-USB, or VISA-RSIB
object, you can use the
clrdevice function to remove
the terminating character.
To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.
serialobject interface is not recommended
Not recommended starting in R2019b