Main Content

Creating a GPIB Object

Using the gpib Function

You create a GPIB object with the gpib function. gpib requires the adaptor name, the GPIB board index, and the primary address of the instrument. As described in Connecting to the Instrument, you can also configure property values during object creation. For a list of supported adaptors, refer to Interface Driver Adaptor.

Each GPIB object is associated with one controller and one instrument. For example, to create a GPIB object associated with a National Instruments® controller with board index 0, and an instrument with primary address 1,

g = gpib('ni',0,1);


You do not use the GPIB board primary address in the GPIB object constructor syntax. You use the board index and the instrument address.

The GPIB object g now exists in the IEEE® workspace. You can display the class of g with the whos command.

whos g
  Name      Size         Bytes  Class

  g         1x1            636  gpib object

Grand total is 14 elements using 636 bytes

Once the GPIB object is created, the following properties are automatically assigned values. These general-purpose properties describe the object based on its class type and address information.

GPIB Descriptive Properties

Property Name



Specify a descriptive name for the GPIB object.


Indicate the object type.

You can display the values of these properties for g with the get function.


ans =



ans =



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.

GPIB Object Display

The GPIB object provides you with a convenient display that summarizes important address and state information. You can invoke the display summary as follows:

  • Type the GPIB object at the command line.

  • Exclude the semicolon when creating a GPIB object.

  • Exclude the semicolon when configuring properties using dot notation.

You can also display summary information via the Workspace browser by right-clicking an instrument object and selecting Display Summary from the context menu.

The display summary for the GPIB object g is:

GPIB Object Using NI Adaptor : GPIB0-1

Communication Address 
   BoardIndex:         0
   PrimaryAddress:     1
   SecondaryAddress:   0

Communication State 
   Status:             closed
   RecordStatus:       off

Read/Write State  
   TransferStatus:     idle
   BytesAvailable:     0
   ValuesReceived:     0
   ValuesSent:         0

Related Topics