Documentation

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.

MLEvalString

Evaluate command in MATLAB

Syntax

MLEvalString(command)
MLEvalString command
out = MLEvalString(command)

Description

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

command

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

out

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.

Examples

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

Tips

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