External Interfaces Previous page   Next Page

Supported Client/Server Configurations

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 that are explained in this section:

MATLAB Client and In-Process Server

With the configuration shown below, the MATLAB client application interacts with a component that has been implemented as an ActiveX control or a dynamic link library (DLL). The server runs in the same process and shares the same address space as the client. Communication between client and server is fast because passing data within the same process requires little overhead.

Figure: Communication between COM client and COM server

The server exposes its properties and methods through the IDispatch (Automation) interface or a custom interface, depending on which of these interfaces are implemented in the component. See Getting Interfaces to the Object for information on accessing interfaces.

ActiveX Controls.   An ActiveX control is an object that usually has some type of graphical user interface (GUI). When MATLAB constructs a control in the server, it places the control's GUI within a MATLAB figure window to enable you to interact with it. By clicking on the various options available in the user interface (e.g., making a particular menu selection), you can trigger events that get communicated from the control in the server to the client MATLAB application. The client decides what to do about each event and responds accordingly.

MATLAB ships with a 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.

DLL Servers.   Any COM component that has been implemented as a dynamic link library (DLL) is also instantiated in an in-process server. That is, it is created in the same process as the MATLAB client application. Unlike a control, the DLL server runs in a separate window rather than a MATLAB figure window.

MATLAB responds to events generated by a DLL server in the same way as events from an ActiveX control.

For More Information.   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

In this configuration, a MATLAB client application interacts with a component that has been implemented as an executable (.exe) file. The executable component is instantiated in a server that runs in a separate process from that of the client application. Communication between client and server is somewhat slower because of the overhead required when passing data across process boundaries. Examples of local servers are Microsoft Excel and Microsoft Word.

Figure: Communication between COM client and COM server

As with in-process servers, this server exposes its properties and methods through the IDispatch (Automation) interface or a custom interface, depending on which of these interfaces are implemented in the component. See Getting Interfaces to the Object for information on accessing interfaces.

Since the client and server run in separate processes, you have the option of creating the server on any system on the same network as the client. This type of configuration is supported only in an environment that supports the Distributed Component Object Model (DCOM).

If the component provides a user interface, this interface is displayed in a separate window from the client application.

MATLAB responds to events generated by an out-of-process server in the same way as events from an ActiveX control.

For More Information.   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 created 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.

Figure: Communication between COM client and COM server

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 start a MATLAB server to run in either a shared or dedicated mode. You also have the option of running it on a local or remote system.

To create the MATLAB server from an external application program, use the appropriate function from that language to instantiate the server. (For example, you would use the CreateObject function in Visual Basic.) For the programmatic identifier, specify matlab.application. To run MATLAB as a dedicated server, specify matlab.application.single as the identifier.

The function that creates the MATLAB server also returns a handle to the properties and methods available in the server through the IDispatch interface. See COM Server Functions for descriptions of these methods and how to call them from a Visual Basic or MATLAB client.

For More Information.   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 that are written in C, C++, or Fortran. MATLAB uses IEngine to communicate between the client application and the MATLAB Engine running as a COM server.

Figure: Communication between COM client and 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. See C Engine Functions and Fortran Engine Functions in the External Interfaces Reference for more information on these.

For More Information.   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.


Previous page  Introducing MATLAB COM Integration Registering Controls and Servers Next page

© 1994-2005 The MathWorks, Inc.