MATLAB Runtime Server | ![]() ![]() |
Trapping Errors
Error trapping helps suppress command-window output and helps your Runtime Server application run more smoothly. It also allows you to design user-friendly features such as context-sensitive error dialog boxes. Wherever the application executes a MATLAB command that could potentially generate an error, use a try
-catch
-end
structure.
In a try
-catch
-end
structure (below), the try
block contains the MATLAB commands that you want the application to evaluate and execute (expression1
and expression2
). If the try
block executes successfully, then the catch
block is ignored. If the try
block generates an error during execution, then the catch
block (expression3
and expression4
) is executed in its place, and the error is suppressed. Use the lasterr
command to find out what the error was.
![]() | Using a Uicontrol or Uimenu to Exit the Application | Setting the Global Error Behavior on a PC | ![]() |