This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Connect to Existing MATLAB Server

It is not always necessary to create a new instance of a MATLAB® server whenever your application needs some task done in MATLAB. Clients can connect to an existing MATLAB Automation server using the actxGetRunningServer function or by using a command similar to the Visual Basic® .NET GetObject command.

Using Visual Basic .NET Code

The Visual Basic .NET command shown here returns a handle h to the MATLAB server application:

h = GetObject(, "matlab.application")


It is important to use the syntax shown above to connect to an existing MATLAB Automation server. Omit the first argument, and make sure the second argument is as shown.

The following Visual Basic .NET example connects to an existing MATLAB server, then executes a plot command in the server. If you do not already have a MATLAB server running, create one following the instructions in Access Methods from the Visual Basic Object Browser.

Dim h As Object
h = GetObject(, "matlab.application") 

' Handle h should be valid now. 
' Test it by calling Execute.
h.Execute ("plot([0 18], [7 23])")
Was this topic helpful?