Graphics Previous page   Next Page

Saving Handles in M-Files

Graphics M-files frequently use handles to access property values and to direct graphics output to a particular target. MATLAB provides utility routines that return the handles to key objects (such as the current figure and axes). In M-files, however, these utilities might not be the best way to obtain handles because

Save Information First

It is good practice to save relevant information about the MATLAB state in the beginning of your M-file. For example, you can begin an M-file with

rather than querying this information each time you need it. Remember that utility commands like ishold obtain the values they return whenever called. (The ishold command issues a number of get commands and string compares (strcmp) to determine the hold state.)

If you are temporarily going to alter the hold state within the M-file, you should save the current values of the NextPlot properties so you can reset them later.


Previous page  Handle Validity Versus Handle Visibility Properties Changed by Built-In Functions Next page

© 1994-2005 The MathWorks, Inc.