Main Content

set

Configure or display OPC object properties

Syntax

set(Obj)
Prop = set(Obj)
set(Obj,'PropertyName')
Prop = set(Obj,'PropertyName')
set(Obj,'PropertyName',PropertyValue)
set(Obj,S)
set(Obj,PN,PV)
set(Obj,'PropName1',PropValue1,'PropName2',PropValue2,...)

Description

set(Obj) displays property names and any enumerated values for all configurable properties of OPC object Obj. Obj must be a single toolbox object.

Prop = set(Obj) returns all property names and their possible values for object Obj. Obj must be a single object. The return value, Prop, is a structure whose field names are the property names of Obj, and whose values are cell arrays of possible property values or empty cell arrays if the property does not have a finite set of possible character vector values.

set(Obj,'PropertyName') displays the possible values for the specified property, PropertyName, of toolbox object Obj. Obj must be a single object.

Prop = set(Obj,'PropertyName') returns the possible values for the specified property, PropertyName, of object Obj. The returned array, Prop, is a cell array of possible value character vectors or an empty cell array if the property does not have a finite set of possible character vector values.

set(Obj,'PropertyName',PropertyValue) sets the value, PropertyValue, of the specified property, PropertyName, for object Obj. Obj can be a vector of toolbox objects, in which case set sets the property values for all the objects specified.

Note that if Obj is connected to an OPC server, configuring server-specific properties such as UpdateRate and DeadbandPercent might be time consuming.

set(Obj,S) where S is a structure whose field names are object property names, sets the properties named in each field name to the values contained in the structure.

set(Obj,PN,PV) sets the properties specified in the cell array of character vectors or string array, PN, to the corresponding values in the cell array PV, for all objects specified in Obj. The cell array PN must be a vector, but the cell array PV can be M-by-N, where M is equal to length(Obj) and N is equal to length(PN), so that each object will be updated with a different set of values for the list of property names contained in PN.

set(Obj,'PropName1',PropValue1,'PropName2',PropValue2,...) sets multiple property values with a single statement.

Note that it is permissible to use name-value pairs, structures, and name-value cell array pairs in the same call to set.

Examples

Create an opcda object and add a group to that object.

da = opcda('localhost','Dummy.Server'); 
grp = addgroup(da,'SetExample');

Set the opcda object’s Timeout to 300 seconds, and restrict the event log to 2000 entries.

set(da,'Timeout',300,'EventLogMax',2000);

Set multiple properties using cell array pairs.

set(da,{'Name','ServerID'},{'My Opcda object','OPC.Server.1'});

Set the group name.

set(grp,'Name','myopcgroup');

Query the permissible values for the group’s Subscription property.

set(grp,'Subscription')

Tips

As an alternative to the set function, you can directly assign property values using dot-notation. The following two lines achieve the same result.

set(daObj,'Timeout',10);
daObj.Timeout = 10;

Version History

Introduced before R2006a

See Also

Functions