isnumeric - Determine whether input is numeric array - MATLAB (original) (raw)

Main Content

Determine whether input is numeric array

Syntax

Description

`TF` = isnumeric([A](#mw%5F2cc97167-e92f-48a3-a3b8-7f0c036ec07c)) returns logical 1 (true) if A is an array of numeric data type. Otherwise, it returns logical 0 (false).

Numeric types in MATLAB® include: int8, int16,int32, int64, uint8,uint16, uint32, uint64,single, and double. For more information, see Integer Classes andFloating-Point Numbers.

example

Examples

collapse all

Determine if a real number is a numeric type.

MATLAB® stores numeric data as a double-precision format by default, which is a numeric type.

Now create a signed 16-bit integer type using int16. Check if it is a numeric type.

TF = isnumeric(int16(-256))

Determine if an array containing infinity or not-a-number values is a numeric type.

Create several calculations that return Inf and assign the results to an array. Check if the array is a numeric type.

MATLAB represents infinity by the special value Inf as a double type.

Create several calculations that return NaN and assign the results to an array. Check if the array is a numeric type.

MATLAB represents not-a-number by the special value NaN, as a double type.

Determine if an array containing floating-point numbers is a numeric type.

A = [-3.5e2 2.5; single(3) pi]

A = 2×2 single matrix

-350.0000 2.5000 3.0000 3.1416

Now create a cell array that contains the array A and other numbers. Use class to identify the type of the cell array. Check if it is a numeric type.

B=2×2 cell array {2×2 single} {[-4]} {[ 2]} {[ 1]}

The cell array is not a numeric type since it is a cell type.

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. MATLAB has the following numeric types.

Integer Type Description
single single-precision floating-point
double double-precision floating-point
int8 8-bit signed integer
int16 16-bit signed integer
int64 64-bit signed integer
int32 32-bit signed integer
uint8 8-bit unsigned integer
uint16 16-bit unsigned integer
uint32 32-bit unsigned integer
uint64 64-bit unsigned integer

Extended Capabilities

expand all

The isnumeric function fully supports GPU arrays. To run the function on a GPU, specify the input data as a gpuArray (Parallel Computing Toolbox). For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a