logical
Determine if symbolic equation, inequality, or condition is true
Syntax
Description
Examples
Input Arguments
Tips
For symbolic equations,
logicalreturns logical1(true) only if the left and right sides are equal. Otherwise, it returns logical0(false).For symbolic inequalities constructed with
~=,logicalreturns logical0(false) only if the left and right sides are equal. Otherwise, it returns logical1(true).For all other inequalities (constructed with
<,<=,>, or>=),logicalreturns logical1if it can prove that the inequality is true and logical0if it can prove that the inequality is false. Iflogicalcannot determine whether an inequality is true or false, it returns an error.logicaldoes not simplify or mathematically transform a conditional statement. To compare a conditional statement applying mathematical transformations and simplifications, useisAlways.If you use
logicalto 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, thenlogicalreturns an error. For example,syms f(x) g(y); tf = logical(f~=g)returns an error.logicalignores assumptions on symbolic variables.
Version History
Introduced in R2012a