isreal
Tests whether an array is stored without an imaginary part.
Category: Language Fundamentals > Data Types
Syntax
tf = isreal(A)
Returns true if A is stored without an imaginary part.
Description
The test concerns how the array is stored, not its value. The result of 3 + 0i is simplified to the real 3, so isreal is true, but complex(3, 0) forces complex storage and gives false. Non-numeric values such as cell arrays and structs also give false.
Input arguments
A- Any value.
Output arguments
tf- Logical scalar.
Example
Real and complex storage
isreal(5)
isreal(1 + 2i)
isreal(3 + 0i)
isreal(complex(3, 0))
isreal(sqrt(-4))
Output
ans = logical
1
ans = logical
0
ans = logical
1
ans = logical
0
ans = logical
0