Main Content

MATLAB COM Integration

Concepts and Terminology

While the ideas behind COM technology are straightforward, the terminology is not. The meaning of COM terms has changed over time and few concise definitions exist. Here are some terms that you should be familiar with. These are not comprehensive definitions. For a complete description of COM, you need to consult outside resources.

COM Objects, Clients, and Servers

A COM object is a software component that conforms to the Component Object Model. COM enforces encapsulation of the object, preventing direct access of its data and implementation. COM objects expose interfaces, which consist of properties, methods and events.

A COM client is a program that makes use of COM objects. COM objects that expose functionality for use are called COM servers. COM servers can be in-process or out-of-process. An example of an out-of-process server is Microsoft® Excel® spreadsheet program.

MATLAB® can be used as either a COM client or a COM Automation server.

Interfaces

The functionality of a component is defined by one or more interfaces. To use a COM component, you must learn about its interfaces, and the methods, properties, and events implemented by the component. The component vendor provides this information.

There are two standard COM interfaces:

  • IUnknown — An interface required by all COM components. All other COM interfaces are derived from IUnknown.

  • IDispatch — An interface that exposes objects, methods, and properties to applications that support Automation.

MATLAB COM Client

A COM client is a program that manipulates COM objects. These objects can run in the MATLAB application or can be part of another application that exposes its objects as a programmatic interface to the application.

Using MATLAB as a COM client provides two techniques for developing programs in MATLAB:

  • You can include COM components in your MATLAB application (for example, a spreadsheet).

  • You can access existing applications that expose objects via Automation.

MATLAB COM clients can access applications that support Automation, such as the Excel spreadsheet program. MATLAB creates an Automation server in which to run the application and returns a handle to the primary interface for the object created.

MATLAB COM Automation Server

Automation provides an infrastructure whereby applications called automation controllers can access and manipulate (that is, set properties of or call methods on) shared automation objects that are exported by other applications, called Automation servers. Any Windows® program that can be configured as an Automation controller can control MATLAB.

For example, using Microsoft Visual Basic® programming language, you can run a MATLAB script in a Microsoft PowerPoint® presentation. In this case, PowerPoint is the controller and MATLAB is the server.

Related Topics