Documentation Center

  • Trial Software
  • Product Updates

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

expand all

Evaluate a MATLAB Command from an Excel Worksheet

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

expand 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™ EX error, such as #COMMAND. To return MATLAB error strings, use MLShowMatlabErrors.

See Also

|

Was this topic helpful?