I have done partial fraction decomposition to a symbolic polynomial in MATLAB, which gives me a symbolic expression like e.g. the following:
poly = -2i/(x - 1.0 - 1.7i) + 0.57i/(x - 1.0 + 1.1559i)
As you see, this symbolic expression contains both x-variables and constant complex numbers. How can I extract all the numeric values from this expression in MATLAB? The information whether the number is real or complex must not be lost.
So for the given expression poly
, how would I get the following matrix A
:
A = [-2i, -1-1.7i; .57i, -1+1.1559i]
A =
0 - 2i -1 - 1.7i
0 + 0.57i -1 + 1.1559i
Please also note that A
should contain numbers, not symbolic expressions as poly
does.
I read of coeffs
-function, but it requires the input being a polynomial.
With children
-function I am able to divide the summation terms in the symbolic expression to vector of symbolic expressions as shown below:
p = - 0.57735026918962576450914878050196i/(x - 1.0 - 1.7320508075688772935274463415059i) + 0.57735026918962576450914878050196i/(x - 1.0 + 1.7320508075688772935274463415059i);
terms = children(p)
terms =
[ -0.57735026918962576450914878050196i/(x - 1.0 - 1.7320508075688772935274463415059i), 0.57735026918962576450914878050196i/(x - 1.0 + 1.7320508075688772935274463415059i)]