External Interfaces/API |
Overview of MATLAB COM Support
You can configure MATLAB to either control or be controlled by other COM components. When MATLAB controls another component, MATLAB is the client, and the other component is the server. When MATLAB is controlled by another component, it is acting as the server.
MATLAB supports four different COM client-server configurations:
The first three configurations communicate using an Automation interface that the client program, in turn, accesses via a COM interface called IDispatch. The last MATLAB configuration uses a faster, custom COM interface called IEngine.
MATLAB Client and In-Process (Control) Server
You would set up the configuration shown here when you want to interact with a COM control. Controls are application components that can be both visually and programmatically integrated into a control container, such as a MATLAB figure window. Some examples of useful controls are the Microsoft Internet Explorer Web Browser control, the Microsoft Windows Communications control for serial port access, and the graphical user interface controls delivered with the Visual Basic development environment.
Your MATLAB application is the Automation client. It "contains" the control, because the control runs in the MATLAB process address space rather than as a separate process. The COM control runs as the Automation server.
You create the control using the MATLAB actxcontrol
function. This function creates a MATLAB figure window and positions the graphical user interface of the control within that window. Users commonly interact with this interface using GUI menus, buttons, etc. Doing so often triggers an event that gets communicated from the control to its client MATLAB application. The client then decides what to do about the event and responds appropriately.
MATLAB ships with a very simple sample ActiveX control that draws a circle on the screen and displays some text. This allows MATLAB users to try out MATLAB COM control support with a known control. For more information, see MATLAB Sample Control.
To learn more about working with MATLAB as a client, see MATLAB COM Client Support and Additional COM Client Information
MATLAB Client and Out-of-Process Server
This configuration runs the server in a separate process from that of the client application. The server is no longer contained by the client process, and it does not run as part of MATLAB in a figure window. Any user interface displayed is in a separate window. Examples of local servers are Microsoft Excel and Microsoft Word.
The client and server use Automation to communicate through a COM IDispatch interface. Since the server runs in a separate process, it may be run on either a local or remote system. There is currently no support for events generated from Automation servers.
The MATLAB actxserver
function creates a COM Automation server and returns a COM object for the server's default interface.
To learn more about working with MATLAB as a client, see MATLAB COM Client Support and Additional COM Client Information
Client Application and MATLAB Automation Server
MATLAB operates as the Automation server in this configuration. It can be launched and controlled by any Windows program that can be an Automation Controller. Some examples of applications that can be Automation Controllers are Microsoft Excel, Microsoft Access, Microsoft Project, and many Visual Basic and Visual C++ programs.
MATLAB Automation server capabilities include the ability to execute commands in the MATLAB workspace, and to get and put matrices directly from and into the workspace. You can launch a MATLAB server to run in either a dedicated or shared mode. You also have the option of running it on a local or remote system.
Note Because VBScript client programs require an Automation interface to communicate with servers, this is the only configuration that will support a VBScript client. |
To learn more about working with MATLAB Automation servers, see MATLAB Automation Server Support and Additional Automation Server Information.
Client Application and MATLAB Engine Server
MATLAB provides a faster, custom interface called IEngine for client applications written in C, C++, or Fortran. MATLAB uses this COM interface to communicate between the client application and the MATLAB Engine running as a COM server. A library of functions is provided with MATLAB that enables you to start and end the server process, and to send commands to be processed by MATLAB.
To learn more about the MATLAB Engine and the functions provided in its C and Fortran libraries, see Calling MATLAB from C and Fortran Programs.
Introducing MATLAB COM Integration | MATLAB COM Client Support |