Main Content

MLShowMatlabErrors

Return standard Spreadsheet Link errors or full MATLAB errors

Description

example

= MLShowMatlabErrors(flag) sets the error message type when executing MATLAB® commands using MLEvalString in Microsoft® Excel®. An error displays when MLEvalString fails. You can display two different types of error messages. At any point, you can switch between displaying Spreadsheet Link™ and MATLAB errors. Without this function, worksheet cells display only Excel error messages. Use this syntax when working in a worksheet cell.

example

MLShowMatlabErrors flag works in a VBA macro.

Examples

collapse all

This Spreadsheet Link code assumes MLEvalString returns MATLAB errors upon failure.

Enter this text in any worksheet cell to display MLEvalString failures as Spreadsheet Link errors.

=MLShowMatlabErrors("no")

Enter this invalid text in any worksheet cell.

=MLEvalString("sum(2+b);")

This Spreadsheet Link error appears in the calling cell.

#COMMAND!

This VBA code assumes MLEvalString returns Spreadsheet Link errors upon failure.

Enter this text at the beginning of a VBA macro to display MLEvalString failures as MATLAB errors.

MLShowMatlabErrors "yes"

Enter this invalid text in the VBA macro.

out = MLEvalString("sum(2+b);")
MsgBox (out)

When running this macro, this MATLAB error appears in a dialog box: ??? Undefined function or variable 'b'. For details on running macros, see Excel Help.

Input Arguments

collapse all

Error message indicator, specified as "no" or "yes" to determine the type of error message displayed when MLEvalString fails. To display the standard Spreadsheet Link errors, specify "no". To display the full MATLAB errors, specify "yes".

Tips

  • To work with VBA code in Excel with Spreadsheet Link, you must enable Spreadsheet Link as a reference in the Microsoft Visual Basic® Editor. For details, see Installation.

Version History

Introduced in R2006b