Write COM Applications to Work with MATLAB
To write applications that call MATLAB as a COM Automation server, consider using the MATLAB Engine API for .NET. For more information, see Call MATLAB from .NET. For examples, see:
Automation is a COM protocol that allows one application (the controller or client) to control objects exported by another application (the server). MATLAB supports COM Automation server capabilities on Microsoft® Windows® operating systems. Any Windows program that can be configured as an Automation client can control MATLAB.
If you need to maintain existing code created for MATLAB R2022a or earlier that calls MATLAB as a COM Automation server, see these topics.
If you build client applications using C, C++, or Fortran, then use MATLAB Engine Applications instead of an Automation server. For more information, see Choosing Engine Applications.
To access COM components from MATLAB, see Use COM Objects in MATLAB.
MATLAB as COM Server
|Matrix from Automation server workspace|
|Matrix in Automation server workspace|
|Character array from Automation server|
|Character array in Automation server|
|Data from variable in Automation server workspace|
|Data from Automation server workspace|
|Data in Automation server workspace|
- Register MATLAB as COM Server
To use MATLAB as a COM server, register the application in the Windows registry.
- Create MATLAB Server
To create a server, use a programmatic identifier (ProgID) to identify the server.
- Convert MATLAB Types to COM Types
How MATLAB converts data from MATLAB types to COM types.
- Convert COM Types to MATLAB Types
How MATLAB converts data from a COM application into MATLAB types.
- Call MATLAB Function from C# Client
This example shows how to call a user-defined MATLAB function from a C# application using MATLAB as an Automation server.
- Call MATLAB Function from Visual Basic .NET Client
This example calls MATLAB functions from a Microsoft Visual Basic® client application.
- Pass Complex Data to MATLAB from C# Client
This example creates complex data in a client C# program and passes it to MATLAB.
Résolution des problèmes
When you call a MATLAB function from another program, the program might display a timeout message while waiting for the MATLAB function to complete.