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.


Evaluate command in MATLAB


MLEvalString command
out = MLEvalString(command)


MLEvalString(command) passes a command string to the MATLAB® software for evaluation. Use this syntax when working directly in a worksheet.

MLEvalString command passes a command string to the MATLAB software for evaluation. Use this syntax in a VBA macro.

out = MLEvalString(command) lets you catch errors when executing MLEvalString in a VBA macro. If MLEvalString fails, then out is a string containing error code or error message. Otherwise, out is 0.

Input Arguments


MATLAB command to evaluate.

command in quotes directly specifies the command. command without quotes specifies a worksheet cell address (or range name) that contains the command.

Output Arguments


0 if the command succeeded. Otherwise, a string containing error code or error message. To return MATLAB error messages instead of error code, use MLShowMatlabErrors.


collapse all

Divide the MATLAB variable b by 2, and then plot it:

MLEvalString("b = b/2;plot(b)")

This command only modifies the MATLAB variable b. To update data in the Excel® worksheet, use MLGetMatrix.

More About

collapse all


  • The specified action alters only the MATLAB workspace. It has no effect on the Microsoft® Excel workspace.

  • If MLEvalString fails, then by default you get a standard Spreadsheet Link™ error, such as #COMMAND. To return MATLAB errors, use MLShowMatlabErrors.

Introduced before R2006a

Was this topic helpful?