External Interfaces/API | ![]() ![]() |
MATLAB ActiveX Automation Server Support
MATLAB on Microsoft Windows supports ActiveX Automation server capabilities. Automation is an ActiveX protocol that allows one application or component (the controller) to control another application or component (the server). Thus, MATLAB 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. Using Automation, you can execute MATLAB commands, and get and put mxArrays
from and to the MATLAB workspace.
To use MATLAB as an automation server, follow steps 1 and 2:
Consult the documentation of your controller to find out how to invoke an
ActiveX Automation server. The name of the MATLAB ActiveX object that
is placed in the registry is Matlab.Application
. Exactly how you invoke the
MATLAB server depends on which controller you choose, but all controllers
require this name to identify the server.
The ActiveX Automation interface to MATLAB supports several methods.
Here is a Visual Basic code fragment that invokes the MATLAB Automation
Execute
method, and that works in Microsoft Excel or any other Visual
Basic or Visual Basic for Applications (VBA)-enabled application. The
Execute
method takes a command string as an argument and returns the
results as a string. The command string can be any command that would
normally be typed in the command window; the result contains any output
that would have been printed to the command window as a result of
executing the string, including errors.
Dim MatLab As Object Dim Result As String Set MatLab = CreateObject("Matlab.Application") Result = MatLab.Execute("surf(peaks)")
Note The first statement above should be declared in the general declarations section in order to keep the scope throughout the application. |
![]() | Using MATLAB As an Automation Client | MATLAB ActiveX Automation Methods | ![]() |