Main Content


Write command to VISA resource and read response

Since R2021a



    response = writeread(v,command) writes the ASCII text command followed by the terminator to the VISA resource v, then reads the ASCII text returned from the resource. You can use this function to query the resource. The function suspends MATLAB® execution until the specified command is sent to the resource and a response is received.


    collapse all

    Create a connection to a VISA resource. This example shows a connection to a Keysight Technologies® (formerly Agilent Technologies®) X-Series Signal Analyzer (N9030A, PXA Signal Analyzer) using the VISA-TCP/IP interface. The specified resource name is unique to this example.

    v = visadev("TCPI0::");

    Write an instrument identification SCPI command to the instrument and read the response.

    ans = 
    "Agilent Technologies,N9030A,US00071181,A.14.16"

    The instrument response to the *IDN? command identifies the name, model, and serial number of the instrument.

    Input Arguments

    collapse all

    VISA resource, specified as a visadev object.

    Example: writeread(v,"*IDN?") sends an ASCII text command to the VISA resource v.

    ASCII text command to write to device, specified as a character vector or string scalar.

    Example: writeread(v,"*IDN?") sends the ASCII command *IDN?.

    Data Types: char | string

    Version History

    Introduced in R2021a