Symbolic subtraction
Subtract 2
from array A
.
syms x A = [x 1;-2 sin(x)]; A - 2
ans = [ x - 2, -1] [ -4, sin(x) - 2]
minus
subtracts 2
from
each element of A
.
Subtract the identity matrix from matrix M
:
syms x y z M = [0 x; y z]; M - eye(2)
ans = [ -1, x] [ y, z - 1]
Subtract one number from another. Because these are not symbolic objects, you receive floating-point results.
11/6 - 5/4
ans = 0.5833
Perform subtraction symbolically by converting the numbers to symbolic objects.
sym(11/6) - sym(5/4)
ans = 7/12
Alternatively, call minus
to perform subtraction.
minus(sym(11/6),sym(5/4))
ans = 7/12
Subtract matrices B
and C
from A
.
A = sym([3 4; 2 1]); B = sym([8 1; 5 2]); C = sym([6 3; 4 9]); Y = A - B - C
Y = [ -11, 0] [ -7, -10]
Use syntax -Y
to negate the elements of Y
.
-Y
ans = [ 11, 0] [ 7, 10]
Subtract function g
from
function f
.
syms f(x) g(x) f = sin(x) + 2*x; y = f - g
y(x) = 2*x - g(x) + sin(x)
All nonscalar arguments must have the same size. If
one input argument is nonscalar, then minus
expands
the scalar into an array of the same size as the nonscalar argument,
with all elements equal to the corresponding scalar.
ctranspose
| ldivide
| mldivide
| mpower
| mrdivide
| mtimes
| plus
| power
| rdivide
| times
| transpose