MATLAB: Can I open multiple instances of MATLAB using ActiveX

activexinstancesMATLABmultipleoleole32

I am trying to set up MATLAB as an ActiveX automation server. However, I noticed MATLAB is using the same environment when two clients are connected. This caused the variables to be corrupted. I would like to be able to generate additional copies of MATLAB having separate environments with new clients.

Best Answer

In MATLAB 5.2 and earlier versions it was not possible to instantiate multiple copies of MATLAB via ActiveX.
As of MATLAB 5.3, it is possible to do this. Instead of using a ProgID of "Matlab.Application" when instantiating MATLAB, use "Matlab.Application.Single". For example use the following:
set Matlab1 = CreateObject("Matlab.Application.Single")
set Matlab2 = CreateObject("Matlab.Application.Single")
This will create two separate instances of MATLAB in Visual Basic. See Chapter 7 of the External Interfaces/API Guide for more details on using MATLAB as an ActiveX automation server: