Matlab: ratio of symbolic polynomials - extract numerator and denominator

327 Views Asked by At

Suppose I have a Matlab expression consisting of a ratio of polynomials of the symbolic variable 'x'. The polynomial coefficients are likewise symbolic. Is there a simple way to extract the numerator and the denominator of the expression? It is fine if the function returns either the polynomials or their coefficients.

1

There are 1 best solutions below

0
Ander Biguri On

Yes there is. If you search google "MATLAB symbolic numerator denominator" the following documentation appears: numden

[N,D] = numden(A)

Example from MATLAB:

syms x y
[n,d] = numden(x/y + y/x)

n = 
x^2 + y^2

d = 
x*y