Contents

Execute

Execute MATLAB command in Automation server

Synopsis

IDL Method Signature

BSTR Execute([in] BSTR command)

Microsoft Visual Basic Client

Execute(command As String) As String

MATLAB Client

result = Execute(h,'command')
result = invoke(h,'Execute','command')

Description

The Execute function executes the MATLAB® statement specified by the string command in the MATLAB Automation server attached to handle h.

The server returns output from the command in the string, result. The result string also contains any MATLAB warning or error messages.

If you terminate the MATLAB command string with a semicolon and there are no warnings or error messages, result might be returned empty.

COM functions are available on Microsoft® Windows® systems only.

Visual Basic .NET Examples

Create a 6-by-6 matrix in the MATLAB server, remove rows 4-6, and return the results to the client.

Dim Matlab As Object
Dim server_version As String
Matlab = CreateObject("matlab.application")
MatLab.PutWorkspaceData("A","base",rand(6))
Matlab.Execute("A(4:6,:) = [];")
Matlab.GetWorkspaceData("A","base",B)

More About

expand all

Tips

If you want to display output from Execute in the client window, specify an output variable, result.

If there is an error, the Execute function returns the MATLAB error message with the characters ??? prepended to the text.

Was this topic helpful?