This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

iptcheckhandle

Check validity of handle

Syntax

iptcheckhandle(obj,valid_types,func_name,var_name,arg_pos)

Description

example

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.

Examples

Trigger Error When Graphics Object Is Not Axes

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

fig = figure; % create figure without an axes
iptcheckhandle(fig,{'axes'},'my_function','my_variable',2)

fig is not an axes handle so iptcheckhandle returns an error message:

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.

Introduced before R2006a