External Interfaces Previous page   Next Page

Additional COM Client Information

Using COM Collections

COM collections are a way to support groups of related COM objects that can be iterated over. A collection is itself a special interface with a Count property (read only), which contains the number of items in the collection, and an Item method, which allows you to retrieve a single item from the collection.

The Item method is indexed, which means that it requires an argument that specifies which item in the collection is being requested. The data type of the index can be any data type that is appropriate for the particular collection and is specific to the control or server that supports the collection. Although integer indices are common, the index could just as easily be a string value. Often, the return value from the Item method is itself an interface. Like all interfaces, this interface should be released when you are finished with it.

This example iterates through the members of a collection. Each member of the collection is itself an interface (called Plot and represented by a MATLAB COM object called hPlot.) In particular, this example iterates through a collection of Plot interfaces, invokes the Redraw method for each interface, and then releases each interface:


Previous page  Examples of MATLAB as an Automation Client Converting Data Next page

© 1994-2005 The MathWorks, Inc.