Execute MATLAB command in Automation server


IDL Method Signature

BSTR Execute([in] BSTR command)

Microsoft Visual Basic Client

Execute(command As String) As String


result = Execute(h,'command')


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.Execute("A(4:6,:) = [];")

More About

expand all


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.

Introduced before R2006a

Was this topic helpful?