Main Content

iptcheckhandle

Check validity of handle

Description

iptcheckhandle(obj,valid_types,func_name,var_name,arg_pos) checks if object obj is a valid graphics object and issues a formatted error message if the handle is invalid.

  • If the object is a valid graphics object as specified by valid_types, then iptcheckhandle returns nothing.

  • If the connectivity argument is invalid, then iptcheckhandle issues a formatted error message that includes information about the function name (func_name), the variable name (var_name), and the argument position (arg_pos). These values are used only to create the error message, not to check whether the graphics object handle is valid.

The figure shows the format of the error message and indicates which parts you can customize using iptcheckhandle arguments.

Formatted error message that includes a function name, argument position, variable name, and the valid types of graphics object.

example

Examples

collapse all

To trigger the error message, create a figure that does not contain an axes object and then check for a valid axes handle. fig is not an axes handle so iptcheckhandle returns an error message.

fig = figure; % create figure without an axes
iptcheckhandle(fig,{'axes'},'my_function','my_variable',2)
Function MY_FUNCTION expected its second input argument, my_variable,
to be one of these types:

 axes

Instead, its type was: figure.

Input Arguments

collapse all

Object, specified as a handle.

Valid types of graphics objects, specified as a cell array containing one or more of these character vectors.

Example: {'uipanel','figure'} specifies that a valid graphics object must be either a panel container or a figure.

Function name to include in an error message when obj is an invalid graphics object, specified as a character vector or string scalar.

Data Types: char | string

Variable name to include in an error message when obj is an invalid graphics object, specified as a character vector or string scalar.

Data Types: char | string

Argument position to include in an error message when obj is an invalid graphics object, specified as a positive integer.

Version History

Introduced before R2006a