Description

validateattributes(A,classes,attributes) validates that array A belongs to at least one of the specified classes (or its subclass) and has all the specified attributes. If A does not meet the criteria, then MATLAB® throws an error and displays a formatted error message. Otherwise, validateattributes completes without displaying any output.

Error using findVolume
Expected input number 1, Shape, to be one of these types:
char
Instead its type was double.
Error in findVolume (line 2)
validateattributes(shape,{'char'},{'nonempty'},mfilename,'Shape',1)

attributes — Valid attributescell array | string array

Valid attributes, specified as a cell array or a string array.

Some attributes also require numeric values, such as attributes that specify the size or number of elements of A. For these attributes, the numeric value or vector must immediately follow the attribute name in a cell array. A string array cannot be used to represent numeric values in attributes.

Name of function for validation, specified as a character vector or as a string scalar. If you specify an empty character vector, '', or the <missing> string, then the validateattributes function ignores the funcName input.

Data Types: char | string

varName — Name of input variablecharacter vector | string scalar

Name of input variable, specified as a character vector or a string scalar. If you specify an empty character vector, '', or the <missing> string, then the validateattributes function ignores the varName input.

Data Types: char | string

argIndex — Position of input argumentpositive integer

Position of input argument, specified as a positive integer.

Data Types: double

Extended Capabilities

C/C++ Code GenerationGenerate C and C++ code using MATLAB® Coder™.

Usage notes and limitations:

Some error messages are a simplified version of the MATLAB error message.

The classes, funcName, varName, and argIndex arguments must be constant.

Attribute names must be constant.

In the generated code, the format of numbers in an error message might be different from the format in MATLAB. For example, here is an error message in MATLAB:

Expected input to be an array with all of the values > 3.

Here is the error message in the generated code:

Expected input to be an array with all of the values > 3.000000000000000e+00.