Main Content

Configuring and Returning Properties

Configuring Property Names and Property Values

You establish the desired instrument object behavior by configuring property values. You can configure property values using the set function or the dot notation, or by specifying property name/property value pairs during object creation. You can return property values using the get function or the dot notation.

Interface objects possess two types of properties: base properties and interface-specific properties. (These properties pertain only to the interface object itself and to the interface, not to the instrument.) Base properties are supported for all interface objects (serial port, GPIB, VISA-VXI, and so on), while interface-specific properties are supported only for objects of a given interface type. For example, the BaudRate property is supported only for serial port and VISA-serial objects.

Device objects also possess two types of properties: base properties and device-specific properties. While device objects possess base properties pertaining to the object and interface, they also possess any number of device-specific properties as defined in the instrument driver for configuring the instrument. For example, a device object representing an oscilloscope might posses such properties as DisplayContrast, InputRange, and MeasurementMode. When you set these properties you are directly configuring the oscilloscope settings.

Returning Property Names and Property Values

Once the instrument object is created, you can use the set function to return all its configurable properties to a variable or to the command line. Additionally, if a property has a finite set of character vector values, set returns these values.

Using Tab Completion for Functions

To get a list of options you can use on the 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 example, when you create a gpib object, you can get a list of installed vendors:

g = gpib('

When you press Tab after the parentheses and single quote, as shown here, the list of installed GPIB vendors displays, such as keysight, ics, mcc, and ni.

The format for the GPIB object constructor function is:

g = gpib('vendor',boardindex,primaryaddress) 

When you press Tab where a field should appear, you get the list of options for that field. The other interface objects, such as Bluetooth®, Serial, TCP/IP, etc., also include this capability on their object constructor functions.

You can also get the values for property-value pairs. For example, to get the possible terminator values when creating a serial object, type:

s = serial('COM1','Terminator',' 

Press Tab after typing the single quote after Terminator to get the possible values for that property, as shown here.

Many of the other toolbox functions also have tab completion. For example, when using the fread function you can specify the precision type using tab completion.

data = fread(s,256,' 

Press Tab after typing the single quote after the size (256 values in this example), since precision is the next argument the fread function takes, to get the possible values for the precision types, such as 'double', 'int16', etc.

When the list of possible values is long, a scroll bar appears in the pop-up window, as shown in this example.

Property Inspector

The Property Inspector enables you to inspect and set properties for one or more instrument objects. It provides a list of all properties and displays their current values.

Settable properties in the list are associated with an editing device that is appropriate for the values accepted by the particular property. For example, a callback configuration GUI to set ErrorFcn, a pop-up menu to set RecordMode, and a text field to specify the TimerPeriod. The values for read-only properties are grayed out.

You open the Property Inspector with the inspect function. Alternatively, you can open the Property Inspector via the Workspace browser by right-clicking an instrument object and selecting Call Property Inspector from the context menu, or by double-clicking the object.