TYPEOF Determine the Type of an Argument

Section: Inspection Functions

Usage

Returns a string describing the type of an array. The syntax for its use is
   y = typeof(x),

The returned string is one of

Example

The following piece of code demonstrates the output of the 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