How to get 'type' of a variable in matlab?
7,132 views (last 30 days)
Sean de Wolski on 15 Nov 2013
Edited: MathWorks Support Team on 27 Nov 2018
To get the data type, or class, of a variable, use the “class” function.
x = 100;
To determine if a variable has a specified data type, use the “isa” function.
tf = isa(x,'double')
For a list of functions that determine if variables have specific attributes, see “is*”.
You also can use the “validateattributes” function, which can validate many classes at once easily.