# isa

Determine if input has specified data type

## Syntax

``tf = isa(A,dataType)``
``tf = isa(A,typeCategory)``

## Description

example

````tf = isa(A,dataType)` returns `1` (`true`) if `A` has the data type specified by `dataType`. Otherwise, it returns `0` (`false`). The input argument `A` can have any data type.If `A` is an object, then `isa` returns `1` if `dataType` is either the class of `A` or a superclass of `A`.```

example

````tf = isa(A,typeCategory)` returns `1` (`true`) if the data type of `A` belongs to the category specified by `typeCategory`. Otherwise, it returns `0` (`false`).If `A` is an object, then `isa` returns `1` if the class of `A`, or any superclass of `A`, belongs to the specified category.```

## Examples

collapse all

Create a numeric variable and determine if its data type is `double`.

```A = 3.1416; tf = isa(A,'double')```
```tf = logical 1 ```

Create an array of 32-bit integers and determine if its data type is `int32`.

`A = int32([0 2 4 6 8])`
```A = 1x5 int32 row vector 0 2 4 6 8 ```
`tf = isa(A,'int32')`
```tf = logical 1 ```

Determine if the data type of `A` is `char`.

`tf = isa(A,'char')`
```tf = logical 0 ```

Create an array whose data type is `uint8`. Determine if the array has a data type that belongs to the `integer` category.

`A = uint8([0 2 4 6 8])`
```A = 1x5 uint8 row vector 0 2 4 6 8 ```
`tf = isa(A,'integer')`
```tf = logical 1 ```

Determine if the data type of `A` belongs to the `float` category.

`tf = isa(A,'float')`
```tf = logical 0 ```

## Input Arguments

collapse all

Input array.

Data type, specified as a character vector or string scalar. `dataType` can be the name of:

• Any fundamental data type or MATLAB® class

• A Java® or .NET class

The table shows the names of many commonly used MATLAB data types.

 `'half'` Half-precision number `'single'` Single-precision number `'double'` Double-precision number `'int8'` Signed 8-bit integer `'int16'` Signed 16-bit integer `'int32'` Signed 32-bit integer `'int64'` Signed 64-bit integer `'uint8'` Unsigned 8-bit integer `'uint16'` Unsigned 16-bit integer `'uint32'` Unsigned 32-bit integer `'uint64'` Unsigned 64-bit integer `'logical'` Logical `1` (`true`) or `0` (`false`) `'char'` Character `'string'` String array `'struct'` Structure array `'cell'` Cell array `'table'` Table `'timetable'` Timetable `'function_handle'` Function handle

Data type category, specified as `'numeric'`, `'float'`, or `'integer'`. These values represent categories of numeric types, as shown in the table.

 `'numeric'` Integer or floating-point array, having one of these data types:`double``single``half``int8``int16``int32``int64``uint8``uint16``uint32``uint64` `'float'` Single- or double-precision floating-point array, having either of these data types:`double``single``half` `'integer'` Signed or unsigned integer array, having one of these data types:`int8``int16``int32``int64``uint8``uint16``uint32``uint64`

## Tips

• To test whether the input array is sparse, use the `issparse` function.

• To test whether the input array has any imaginary or complex elements, use `~isreal(A)`.

## Version History

Introduced before R2006a