Main Content

instrfind

(To be removed) Read instrument objects from memory to MATLAB workspace

This function that uses serial, Bluetooth, tcpip, udp, visa, gpib, or i2c will be removed in a future release. Use serialport, bluetooth, tcpclient, tcpserver, udpport, visadev, aardvark/device, or ni845x/device instead. For more information on updating your code, see Version History.

Syntax

out = instrfind
out = instrfind('PropertyName',PropertyValue,...)
out = instrfind(S)
out = instrfind(obj,'PropertyName',PropertyValue,...)

Arguments

'PropertyName'

A property name for obj.

PropertyValue

A property value supported by PropertyName.

S

A structure of property names and property values.

obj

An instrument object, or an array of instrument objects.

out

An array of instrument objects.

Description

out = instrfind returns all valid instrument objects as an array to out.

out = instrfind('PropertyName',PropertyValue,...) returns an array of instrument objects whose property names and property values match those specified.

out = instrfind(S) returns an array of instrument objects whose property names and property values match those defined in the structure S. The field names of S are the property names, while the field values are the associated property values.

out = instrfind(obj,'PropertyName',PropertyValue,...) restricts the search for matching property name/property value pairs to the instrument objects listed in obj.

Examples

Suppose you create the following two GPIB objects.

g1 = gpib('ni',0,1);
g2 = gpib('ni',0,2);
g2.EOSCharCode = 'CR';
fopen([g1 g2])

You can use instrfind to return instrument objects based on property values.

out1 = instrfind('Type','gpib');
out2 = instrfind({'Type','EOSCharCode'},{'gpib','CR'});

You can also use instrfind to return cleared instrument objects to the MATLAB® workspace.

clear g1 g2
newobjs = instrfind

Instrument Object Array
   Index:   Type:          Status:     Name:  
   1        gpib           open        GPIB0-1
   2        gpib           open        GPIB0-2

Assign the instrument objects their original names.

g1 = newobjs(1);
g2 = newobjs(2);

Close both g1 and g2.

fclose(newobjs)

Tips

instrfind will not return an instrument object if its ObjectVisibility property is configured to off.

You must specify property values using the same format property requires. For example, if the Name property value is specified as MyObject, instrfind will not find an object with a Name property value of myobject. However, this is not the case for properties that have a finite set of character vector values. For example, instrfind will find an object with a Parity property value of Even or even. You can use the propinfo function to determine if a property has a finite set of character vector values.

If you want to clear all of the objects that are found with instrfind, you can use the instrreset function.

You can use property name/property value character vector pairs, structures, and cell array pairs in the same call to instrfind.

Note

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.

Version History

Introduced before R2006a

expand all

R2024b: Warns

Updates to icdevice will result in the future removal of the following functions.

To accommodate the transition, the icdevice function now has a new name-value argument called LegacyMode.

  • LegacyMode=true (default) creates an icdevice object using the legacy mode, consistent with past releases. In this mode, these properties and functions continue to operate.

  • LegacyMode=false creates an icdevice object in the new mode. Use of the mentioned properties and functions might generate warnings or errors. You cannot combine this mode with name-value arguments for any of the properties being removed. This option is required when combining usage with icdevicefind.

FunctionalityUse This InsteadAdditional Information
instrfindicdevicefind

To use replacement, call icdevice with name-value argument LegacyMode=false

instrfindallicdevicefind

To use replacement, call icdevice with name-value argument LegacyMode=false

It is recommended that you update your code to use the new icdevice mode as soon as possible.

See Also

| |