logical
Determine if symbolic equation, inequality, or condition is true
Syntax
Description
Examples
Input Arguments
Tips
For symbolic equations,
logical
returns logical1
(true
) only if the left and right sides are equal. Otherwise, it returns logical0
(false
).For symbolic inequalities constructed with
~=
,logical
returns logical0
(false
) only if the left and right sides are equal. Otherwise, it returns logical1
(true
).For all other inequalities (constructed with
<
,<=
,>
, or>=
),logical
returns logical1
if it can prove that the inequality is true and logical0
if it can prove that the inequality is false. Iflogical
cannot determine whether an inequality is true or false, it returns an error.logical
does not simplify or mathematically transform a conditional statement. To compare a conditional statement applying mathematical transformations and simplifications, useisAlways
.If you use
logical
to check a conditional statement that involves a symbolic type, then the data types of the compared expressions must be compatible. For example,logical(1==sym(1))
returns1
(true
). If the expressions do not have compatible data types, thenlogical
returns an error. For example,syms f(x) g(y); tf = logical(f~=g)
returns an error.logical
ignores assumptions on symbolic variables.
Version History
Introduced in R2012a