MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

The result is a matrix of logical values of the same size as A. arrayfun(@islogical,A)
always returns a matrix of all logical 1 (true) or logical 0 (false) values.


Summary Table


Use these MATLAB functions to determine if an array is logical.


Function Syntax Output Size Description
whos(A) N/A Displays the name, size,
storage bytes, class, and
attributes of variable A.
islogical(A) scalar Returns logical 1 (true) if A
is a logical array; otherwise,
it returns logical 0 (false).
The result is the same as
using isa(A,'logical').
isa(A,'logical') scalar Returns logical 1 (true) if A
is a logical array; otherwise,
it returns logical 0 (false).
The result is the same as
using islogical(A).
class(A) single string Returns a string with the
name of the class of variable
A.
cellfun('islogical',A
)

Array of the same size as A For cell arrays only. Returns
logical 1 (true) for each
cell that contains a logical
array; otherwise, it returns
logical 0 (false).
arrayfun(@islogical,A
)

Array of the same size as A Returns an array of logical 1
(true) values if A is logical;
otherwise, it returns an
array of logical 0 (false)
values.

Determine if Arrays Are Logical
Free download pdf