|On this page…|
To create an interface object, you call functions called object creation functions (or object constructors). These files are implemented using MATLAB® object-oriented programming capabilities, which are described in the MATLAB documentation.
Interface Object Creation Functions
Create a GPIB object.
Create a serial port object.
Create a TCPIP object.
Create a UDP object.
Create a VISA-GPIB, VISA-VXI, VISA-GPIB-VXI, or VISA-serial object.
|bluetooth||Create a Bluetooth object.|
|i2c||Create an I2C object.|
You can find out how to create an interface object for a particular interface and adaptor with the ObjectConstructorName field of the instrhwinfo function. For example, to find out how to create a GPIB object for a National Instruments® GPIB controller,
out = instrhwinfo('gpib','ni'); out.ObjectConstructorName ans = 'gpib('ni', 0, 1);'
Instrument objects contain properties that reflect the functionality of your instrument. You control the behavior of your instrument control application by configuring values for these properties.
As described in Configuring and Returning Properties, you configure properties using the set function or the dot notation. You can also configure properties during object creation by specifying property name/property value pairs. For example, the following command configures the EOSMode and EOSCharCode properties for the GPIB object g:
g = gpib('ni',0,1,'EOSMode','read','EOSCharCode','CR');
If you specify an invalid property name or property value, the object is not created. For detailed property descriptions, refer to the properties documentation.
In the MATLAB workspace, you can create an array from existing variables by concatenating those variables. The same is true for instrument objects. For example, suppose you create the GPIB objects g1 and g2:
g1 = gpib('ni',0,1); g2 = gpib('ni',0,2);
You can now create an instrument object array consisting of g1 and g2 using the usual MATLAB syntax. To create the row array x:
x = [g1 g2] Instrument Object Array Index: Type: Status: Name: 1 gpib closed GPIB0-1 2 gpib closed GPIB0-2
To create the column array y:
y = [g1;g2];
Note that you cannot create a matrix of instrument objects. For example, you cannot create the matrix
z = [g1 g2;g1 g2]; ??? Error using ==> gpib/vertcat Only a row or column vector of instrument objects can be created.
Depending on your application, you might want to pass an array of instrument objects to a function. For example, using one call to the set function, you can configure both g1 and g2 to the same property value.
x.EOSMode = 'read'
Refer to the functions documentation to see which functions accept an instrument object array as an input argument.