Method on @symfun: minus (f, g)
Operator on @symfun: f - g

Subtract one symbolic function from another.

Example:

syms x
f(x) = 2*x;
g(x) = sin(x);

h = f - g
  ⇒ h(x) = (symfun) 2⋅x - sin(x)

Matrix example:

syms x y
f(x, y) = sym([1 12; 13 4]);
g(x, y) = [x 0; 0 y];

h = g - f
  ⇒ h(x, y) = (symfun)
      ⎡x - 1    -12 ⎤
      ⎢             ⎥
      ⎣ -13    y - 4⎦

See also: @symfun/plus, @symfun/uminus.

Package: symbolic