| Programming |     ![]()  | 
Error Control -- try, catch
Error control statements provide a way for you to take certain actions in the event of an error. Use the try statement to test whether a certain command in your code generates an error. If an error does occur within the try block, MATLAB immediately jumps to the corresponding catch block. The catch part of the statement needs to respond in some way to the error.
The general form of a try-catch statement sequence is
In this sequence, the statements between try and catch are executed until an error occurs. The statements between catch and end are then executed. Use lasterr to see the cause of the error. If an error occurs between catch and end, MATLAB terminates execution unless another try-catch sequence has been established.
   | Loop Control -- for, while, continue, break | Program Termination -- return | ![]()  | 
© 1994-2005 The MathWorks, Inc.