Method on @sym: [N, D] = numden (f)

Extract numerator and denominator of a symbolic expression.

Examples:

f = sym(5)/6;
[N, D] = numden (f)
  ⇒ N = (sym) 5
  ⇒ D = (sym) 6

syms x
f = (x^2+2*x-1)/(2*x^3+9*x^2+6*x+3)
  ⇒ f = (sym)
            2
           x  + 2⋅x - 1
      ─────────────────────
         3      2
      2⋅x  + 9⋅x  + 6⋅x + 3

[N, D] = numden (f)
  ⇒ N = (sym)
       2
      x  + 2⋅x - 1

  ⇒ D = (sym)
         3      2
      2⋅x  + 9⋅x  + 6⋅x + 3

f can be a matrix, for example:

f = [1/x  exp(x)  exp(-x)];
[N, D] = numden (f)
  ⇒ N = (sym 1×3 matrix)
      ⎡    x   ⎤
      ⎣1  ℯ   1⎦

  ⇒ D = (sym 1×3 matrix)
      ⎡       x⎤
      ⎣x  1  ℯ ⎦

See also: @sym/partfrac, @sym/children, @sym/coeffs, @sym/children, @sym/lhs, @sym/rhs.

Package: symbolic