MATLAB: What is defined as an integer type, when calling validateattributes

inputparserintegerMATLABtypecheck

Hi,
since
isinteger(int8(5))
is true, I would expect
function c = minimalExample(a)
p = inputParser;
addRequired(p,'a',@(x)validateattributes(x,{'integer'}, {'positive'}));
parse(p,a)
c = a;
end
to return
ans = int8 5.
when calling minimalExample(int8(5)). But it does not. It returns:
The value of 'a' is invalid. Expected input to be one of these types:
integer
Instead its type was int8.
However
function c = minimalExample(a)
p = inputParser;
addRequired(p,'a',@(x)validateattributes(x,{'int8','int16', 'int32', 'int64', 'uint8','uint16', 'uint32', 'uint64'}, {'positive'}));
parse(p,a)
c = a;
end
when calling minimalExample(int8(5)) works fine. What in the name of Knuth is an 'integer' type? Thanks in advance :).

Best Answer

Lets read the validateattributes documentation, and see what it says.
All of its calling syntaxes start with the exactly same three arguments:
validateattributes(A,classes,attributes,...)
The 'integer' option is listed in the section for the third input argument attributes:
I do not see 'integer' anywhere in the section for the second input argument classes.
But you used 'integer' for the second input argument, which as far as I can tell from reading the documentation, is not supported (it would be nice if it threw an error when that occurs...).
"What in the name of Knuth is an 'integer' type?"
Nothing. It doesn't exist.
I suspect you want something like this:
validateattributes(x,{'numeric'}, {'integer','positive'})