Main Content

iptcheckinput

Check validity of array

iptcheckinput will be removed in a future release. Use validateattributes instead.

Description

example

iptcheckinput(A,valid_classes,valid_attributes, func_name,var_name,arg_pos) checks the validity of the input array A and issues a formatted error message if the array is invalid.

  • If the array has valid class and attributes as specified by valid_classes and valid_attributes, then iptcheckinput returns nothing.

  • If the class or attributes are invalid, then iptcheckinput 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 array is valid.

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

Formatted error message that includes a function name, argument position, variable name, and attributes of a valid array.

Examples

collapse all

To trigger this error message, create a 3-D array and then check for the attribute '2d'. C is not 2-D so iptcheckinput returns an error message.

A = [ 1 2 3; 4 5 6 ];
B = [ 7 8 9; 10 11 12];
C = cat(3,A,B);
iptcheckinput(C,{'numeric'},{'2d'},'func_name','var_name',2)
Function FUNC_NAME expected its second input, var_name, to be two-dimensional.

Input Arguments

collapse all

Input array, specified as an array.

Valid classes of array A, specified as a cell array of character vectors. The tables list common classes for image processing applications.

Numeric Classes

int8uint8single
int16uint16double
int32uint32 
int64uint64 

Other Common Classes

categoricalcharcell
function_handlelogicalstring
structtable 

You can use 'numeric' as an abbreviation for the set of classes uint8, uint16, uint32, int8, int16, int32, single, and double.

Example: {'logical' 'cell'} specifies that a valid array must be a logical array or a cell array.

Valid attributes of array A, specified as a cell array of character vectors. The table lists the supported attributes in alphabetical order.

2dcolumnevenfinite
integernonemptynonnannonnegative
nonsparsenonzerooddpositive
realrowscalar

twod

vector

   

If you specify valid_attributes as the empty cell array {}, then iptcheckinput does not check the attributes of A.

Example: {'real' 'nonempty' 'finite'} specifies that a valid array must be real and nonempty and contain only finite values.

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

Data Types: char | string

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

Data Types: char | string

Argument position to include in an error message when A is an invalid array, specified as a positive integer.

Version History

Introduced before R2006a