This is machine translation

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


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 command in the MATLAB Automation server attached to handle h.

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

If you terminate the MATLAB command with a semicolon and there are no warnings or error messages, result might be 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

collapse 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?