How to get the type of a variable in MATLAB?

Dónal picture Dónal · Feb 23, 2009 · Viewed 197.3k times · Source

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

Answer

Daniel LeCheminant picture Daniel LeCheminant · Feb 23, 2009

Use the class function

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