Section: Inspection Functions
y = typeof(x),
The returned string is one of
'cell'
for cell-arrays
'struct'
for structure-arrays
'logical'
for logical arrays
'uint8'
for unsigned 8-bit integers
'int8'
for signed 8-bit integers
'uint16'
for unsigned 16-bit integers
'int16'
for signed 16-bit integers
'uint32'
for unsigned 32-bit integers
'int32'
for signed 32-bit integers
'float'
for 32-bit floating point numbers
'double'
for 64-bit floating point numbers
'complex'
for complex floating point numbers with 32-bits per field
'dcomplex'
for complex floating point numbers with 64-bits per field
'string'
for string arrays
typeof
command for each possible type. The first example is with a simple cell array.
--> typeof({1}) ans = cell --> quit
The next example uses the struct
constructor to make a simple scalar struct.
--> typeof(struct('foo',3)) ans = struct --> quit
The next example uses a comparison between two scalar integers to generate a scalar logical type.
--> typeof(3>5) ans = logical --> quit
For the smaller integers, and the 32-bit unsigned integer types, the typecast operations are used to generate the arguments.
--> typeof(uint8(3)) ans = uint8 --> typeof(int8(8)) ans = int8 --> typeof(uint16(3)) ans = uint16 --> typeof(int16(8)) ans = int16 --> typeof(uint32(3)) ans = uint32 --> quit
The 32-bit signed integer type is the default for integer arguments.
--> typeof(-3) ans = int32 --> typeof(8) ans = int32 --> quit
Float, double, complex and double-precision complex types can be created using the suffixes.
--> typeof(1.0f) ans = float --> typeof(1.0D) ans = double --> typeof(1.0f+i) ans = complex --> typeof(1.0D+2.0D*i) ans = dcomplex --> quit