Include Special Characters..................... 25-12
Create and Share Toolboxes...................... 25-13
Create Toolbox.............................. 25-13
Share Toolbox............................... 25-21
Software Development
Error Handling
26
Exception Handling in a MATLAB Application........ 26-2
Overview................................... 26-2
Getting an Exception at the Command Line......... 26-2
Getting an Exception in Your Program Code ......... 26-3
Generating a New Exception.................... 26-4
Capture Information About Exceptions.............. 26-5
Overview................................... 26-5
The MException Class......................... 26-5
Properties of the MException Class............... 26-6
Methods of the MException Class................ 26-14
Throw an Exception ............................. 26-16
Suggestions on How to Throw an Exception........ 26-16
Respond to an Exception........................ 26-19
Overview.................................. 26-19
The try/catch Statement....................... 26-19
Suggestions on How to Handle an Exception....... 26-21
Clean Up When Functions Complete ............... 26-24
Overview.................................. 26-24
Examples of Cleaning Up a Program Upon Exit...... 26-25
Retrieving Information About the Cleanup Routine ... 26-27
Using onCleanup Versus try/catch ............... 26-28
onCleanup in Scripts......................... 26-29
xxvi Contents