Remove OPC Toolbox objects from memory
delete(Obj) removes the OPC Toolbox™ object Obj from memory. Obj can be an array of objects. A deleted object becomes invalid and you cannot reconnect it to the server after it has been deleted, so you should remove references to that object from the workspace with the clear command. Deleting an object that contains children (groups or items) also deletes these children, so you should remove references to these children.
If multiple references to a toolbox object exist in the workspace, then deleting one object invalidates the remaining references.
If Obj is an opcda object connected to the server, delete disconnects and deletes the object.
Create an OPC HDA Client, delete the object, and clear the variable from the workspace:
hdaObj = opchda('localhost', 'Matrikon.OPC.Simulation'); delete(hdaObj); clear hdaObj
Delete a group and its children from memory:
da = opcda('localhost','Matrikon.OPC.Simulation'); connect(da); grp = addgroup(da,'DeleteEx'); itm = additem(grp,'Random.Real4'); r = read(grp) delete(grp); % deletes itm as well clear grp itm