Main Content


Read data from VISA resource

Since R2021a


    data = read(v,count) reads the number of values specified by count from the VISA resource v and returns the data as a row or column vector of doubles or text. The function suspends MATLAB® execution until the specified number of values is read or a timeout occurs.


    data = read(v,count,datatype) reads the number of values specified by count in the form specified by datatype and returns the data. The datatype argument is a character vector of a standard MATLAB data type. For all numeric datatype types, data is a row vector of double values. For the text type datatype values of "char" or "string", data is of the specified type.


    collapse all

    Create a connection to a VISA resource. This example shows a connection to a device with the alias COM4 using the VISA-Serial interface.

    v = visadev("COM4");

    Read five values of uint32 data from the VISA resource v.

    data = read(v,5,"uint32");

    The five values are a total of 20 bytes of uint32 data.

    Input Arguments

    collapse all

    VISA resource, specified as a visadev object.

    Example: read(v,5) reads data from the VISA resource v.

    Number of values to read, specified as a positive integer value. If count is greater than the NumBytesAvailable property of v, the function suspends MATLAB execution and waits until it reads the specified amount of data or a timeout occurs.

    Example: read(v,2) reads two values of uint8 data.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Size and format of each value, specified as a character vector or string. datatype determines the number of bytes to read for each value and the interpretation of those bytes as a MATLAB data type.

    Example: read(v,1,"uint16") reads one value of uint16 data. Each uint16 value is two bytes.

    Data Types: char | string

    Version History

    Introduced in R2021a

    See Also

    | |