Logical AND for symbolic expressions
Construct and Set Assumptions Using AND
Combine symbolic inequalities into one condition by using
syms x y cond = x>=0 & y>=0;
Set the assumptions represented by the condition using
Verify that the assumptions are set.
ans = [ 0 <= x, 0 <= y]
Evaluate Inequalities or Conditions
Define a range for a variable by combining two inequalities into a
logical condition using
syms x range = 0 < x & x < 1;
Return the condition at
subs function does not evaluate the conditions
x1 = subs(range,x,1/2) x2 = subs(range,x,10)
x1 = 0 < 1/2 & 1/2 < 1 x2 = 0 < 10 & 10 < 1
Evaluate the inequalities to logical
ans = logical 1 ans = logical 0
B — Operands
symbolic equations | symbolic inequalities | symbolic expressions | symbolic arrays
Operands, specified as symbolic equations, inequalities, expressions, or arrays.
B must either be the same size or
have sizes that are compatible (for example,
A is an
N matrix and
B is a
N row vector). For more
information, see Compatible Array Sizes for Basic Operations.
Version HistoryIntroduced in R2012a
R2016b: Implicit expansion change affects arguments for operators
Behavior changed in R2016b
Starting in R2016b with the addition of implicit expansion, some combinations of
arguments for basic operations that previously returned errors now produce results. For
example, you previously could not add a row and a column vector, but those operands are now
valid for addition. In other words, an expression like
[1 2] + [1; 2]
previously returned a size mismatch error, but now it executes.
If your code uses element-wise operators and relies on the errors that MATLAB® previously returned for mismatched sizes, particularly within a
catch block, then your code might no longer
catch those errors.
For more information on the required input sizes for basic array operations, see Compatible Array Sizes for Basic Operations.