External Interfaces |
Connecting to an Existing Server
It is not always necessary to create a new instance of a MATLAB server whenever your application needs some task done within MATLAB. Clients can connect to an existing MATLAB automation server using a command similar to the Visual Basic GetObject
command.
The Visual Basic command shown here returns a handle h
to MATLAB server application:
Note It is important to use the syntax shown above to connect with an existing MATLAB automation server. Omit the first argument, and make sure that the second argument reads exactly as shown. |
The sample Visual Basic code shown here connects to an existing MATLAB server, and then executes a plot command in the server. If you do not already have a MATLAB server running, then you can create one following the instructions in Creating the Automation Server.
Then, enter the following code in a Visual Basic program to connect to the server and have MATLAB draw a simple plot:
Dim h As Object Set h = GetObject(, "matlab.application") ' Handle h should be valid now. Test it by calling Execute. h.Execute ("plot([0 18], [7 23])")
MATLAB Automation Server Support | Automation Server Functions |
© 1994-2005 The MathWorks, Inc.