How to get the type of a variable in MATLAB

Does MATLAB have a function/operator that indicates the type of a variable (similar to the typeof operator in JavaScript)?


Use the class function:

>> b = 2
b =
     2
>> a = 'Hi'
a =
Hi
>> class(b)
ans =
double
>> class(a)
ans =
char

The class() function is the equivalent of typeof().

You can also use isa() to check if a variable is of a particular type. If you want to be even more specific, you can use ischar(), isfloat(), iscell(), etc.