|On this page…|
To create a server, you need a programmatic identifier (ProgID) to identify the server. The ProgID for MATLAB® is matlab.application. For other MATLAB ProgIDs, see Programmatic Identifiers.
How you create an Automation server depends on the controller you are using. Consult your controller's documentation for this information.
If your controller is a MATLAB application and your server is another MATLAB application, you create the Automation server using the actxserver function:
h = actxserver('matlab.application') h = COM.matlab.application
This command automatically creates the Automation server. You can also create the server manually. See Manually Create Automation Server.
The MATLAB Automation server starts up in the matlabroot\bin\win32 folder. If this is not the MATLAB startup folder, the newly created server does not run the MATLAB startup file (startup.m) and does not have access to files in that folder.
To access files in the startup folder, do one of the following:
Use the enableservice function to determine the current state of a MATLAB Automation server. The function returns a logical value, where logical 1 (true) means MATLAB is an Automation server and logical 0 (false) means MATLAB is not an Automation server.
For example, if you type:
and MATLAB displays:
ans = 1
then MATLAB is currently an Automation server.
If you use a Visual Basic® client application to access a MATLAB Automation server, you have two options for creating the server:
You can use the Object Browser of your Visual Basic client application to see what methods are available from a MATLAB Automation server. To do this you need to reference the MATLAB type library in your Visual Basic project.
To set up your Visual Basic project:
In your Visual Basic code, use the New method to create the server:
Matlab = New MLApp.MLApp
View MATLAB Automation methods from the Visual Basic Object Browser under the Library called MLAPP.
To use the Visual Basic CreateObject method, type:
MatLab = CreateObject("Matlab.Application")