Order of Argument Validation ............................
26-16
Avoiding Class and Size Conversions ......................
26-17
nargin in Argument Validation ...........................
26-19
Restrictions on Variable and Function Access ................
26-20
Debugging Arguments Blocks ............................
26-21
Argument Validation Functions ............................
26-22
Numeric Value Attributes ...............................
26-22
Comparison with Other Values ...........................
26-23
Data Types ..........................................
26-23
Size ...............................................
26-23
Membership and Range ................................
26-24
Text ...............................................
26-24
Define Validation Functions .............................
26-24
Ways to Parse Function Inputs .............................
26-26
Function Argument Validation ...........................
26-26
validateattributes .....................................
26-26
inputParser .........................................
26-26
Transparency in MATLAB Code ............................
26-27
Writing Transparent Code ..............................
26-27
Software Development
Error Handling
27
Exception Handling in a MATLAB Application .................
27-2
Overview ............................................
27-2
Getting an Exception at the Command Line ..................
27-2
Getting an Exception in Your Program Code ..................
27-3
Generating a New Exception .............................
27-3
Throw an Exception .......................................
27-4
Suggestions on How to Throw an Exception ..................
27-4
Respond to an Exception ...................................
27-6
Overview ............................................
27-6
The try/catch Statement .................................
27-6
Suggestions on How to Handle an Exception .................
27-7
Clean Up When Functions Complete .........................
27-9
Overview ............................................
27-9
Examples of Cleaning Up a Program Upon Exit ...............
27-10
Retrieving Information About the Cleanup Routine ............
27-11
Using onCleanup Versus try/catch ........................
27-12
onCleanup in Scripts ..................................
27-12
xxii
Contents
Précédent

- 22/1450

Suivant