isnumeric
Determine whether input is numeric array
Syntax
Description
returns
logical TF
= isnumeric(A
)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 and
Floating-Point Numbers.
Examples
Determine Whether Number Is Numeric Type
Determine if a real number is a numeric type.
TF = isnumeric(2)
TF = logical
1
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))
TF = logical
1
Determine Whether Infinity and NaN Are Numeric Type
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.
A = [1/0 log(0) 1e1000]
A = 1×3
Inf -Inf Inf
TF = isnumeric(A)
TF = logical
1
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.
A = [0/0 -Inf/Inf]
A = 1×2
NaN NaN
TF = isnumeric(A)
TF = logical
1
MATLAB represents not-a-number by the special value NaN
, as a double
type.
Determine Whether Arrays Are Numeric Type
Determine if an array containing floating-point numbers is a numeric type.
A = [-3.5e2 2.5; single(3) pi]
A = 2x2 single matrix
-350.0000 2.5000
3.0000 3.1416
TF = isnumeric(A)
TF = logical
1
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 = {A -4; 2 1}
B=2×2 cell array
{2x2 single} {[-4]}
{[ 2]} {[ 1]}
type = class(B)
type = 'cell'
TF = isnumeric(B)
TF = logical
0
The cell array is not a numeric type since it is a cell type.
Input Arguments
A
— Input array
scalar | vector | matrix | multidimensional array
Input array, specified as a scalar, vector, matrix, or multidimensional array. MATLAB has the following numeric types.
Integer Type | Description |
---|---|
single-precision floating-point | |
double-precision floating-point | |
8-bit signed integer | |
16-bit signed integer | |
64-bit signed integer | |
32-bit signed integer | |
8-bit unsigned integer | |
16-bit unsigned integer | |
32-bit unsigned integer | |
64-bit unsigned integer |
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
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).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006a
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)