Connect OPC Toolbox client to server
connect(Obj) connects the opcda or opchda object Obj to the OPC server that you specified by the Host and ServerID properties. When you connect Obj, the Status property takes the value 'connected'. You can disconnect Obj from the server with the disconnect function. When you disconnect Obj, the Status property takes the value 'disconnected'.
If Obj is an array of objects and the function cannot connect some of these objects, it generates a warning message. If the function can connect none of the objects, it generates an error message.
It is possible to create opcda groups and items before connecting to the server. However, servers impose restrictions on client group and item names. Therefore, if you create a group hierarchy and then connect to the server, connect automatically deletes groups or items that the server cannot support, and issues a warning message.
Create a Data Access client and connect to the server:
da = opcda('localhost', 'Matrikon.OPC.Simulation'); connect(da);
Create an HDA client for the Matrikon™ Simulation Server and connect to the server:
hdaObj = opchda('localhost', 'Matrikon.OPC.Simulation'); connect(hdaObj);