External Interfaces/API    

Creating COM Objects

To create a COM Automation control or server in MATLAB, use one of the two functions shown here.

Function
Description
actxcontrol
Create a COM Automation control
actxserver
Create a COM Automation server

Both of these functions require an argument called the ProgID. This is a string that is defined by the vendor and can be obtained from the vendor's documentation. For example, the ProgID for MATLAB is matlab.application.

actxcontrol and actxserver create an object that is an instance of the MATLAB com class. These functions return a handle to the object that you use to reference the object in other COM function calls.

This example creates a COM server application running Excel. The returned handle is assigned to h:

Getting Interfaces from an Object

Once an object has been created, you can obtain interfaces from it, either by assigning an Interface property from the object or by invoking certain methods on it.

This example creates a Workbooks interface to the Excel application using the get function. The get function returns an interface handle that is assigned here to w. Use this handle in other COM function calls as a reference to this interface:

Repositioning a Control

When MATLAB creates a COM control, it places the control figure inside of a MATLAB figure window. You can create the figure window yourself and specify the control's initial position in the window with the actxcontrol function:

Once a control has been created, you can change its shape and position in the window with the move function.

Function
Description
move
Resize or reposition a control in its parent window

Observe what happens to the object in your figure window when you specify new origin coordinates (70, 120) and a new height dimension (100):


  MATLAB COM Client Support Object Properties