Home > Back-end >  Weird problem of matlab when using coeffs and collect
Weird problem of matlab when using coeffs and collect

Time:10-05

Here is the code.

expr = 3/z   2*z^2   7*z^3;
[cx,tx] = coeffs(expr)

This below is the error mesage.

Error using symengine Polynomial expression expected.

Error in sym/mupadmexnout (line 1177) out = mupadmex(fcn,args{:});

Error in sym/coeffs (line 62) [cSym,tSym] = mupadmexnout('symobj::coeffsterms', p, args{:});

Another problem when using collect.

syms t z
sympref('PolynomialDisplayStyle','ascend');

a = 5;
n(t) = taylor(cos(t),t,'ExpansionPoint',pi,'Order',a);
s1(t) = taylor(1/(t^2),t,'ExpansionPoint',pi,'Order',a);
s2(t) = 1/(t-pi)^3;
nu(z) = subs(n, t-pi, z)
s(z) = expand(subs(s1 * s2, t-pi, z));
laurent(z) = expand(nu * s)
expr = 3/z   2*z^2   7*z^3;
coeffs_z = collect(laurent,z)

$$\frac{-5,z^8 {\left(4,\pi \right)},z^7 {\left(60-3,\pi^2 \right)},z^6 {\left(2,\pi^3 -48,\pi \right)},z^5 {\left(36,\pi^2 -\pi^4 -120\right)},z^4 {\left(96,\pi -24,\pi^3 \right)},z^3 {\left(12,\pi^4 -72,\pi^2 \right)},z^2 {\left(48,\pi^3 \right)},z-24,\pi^4 }{{\left(24,\pi^6 \right)},z^3 }$$

output matlab

It has the denominator 24pi^6z^3. How can I get rid of this denominator?

CodePudding user response:

From the error message:

Error using symengine Polynomial expression expected.

From the documentation:

C = coeffs(p) returns coefficients of the polynomial p with respect to all variables determined in p by symvar.

The expression expr = 3/z 2*z^2 7*z^3; is not a polynomial (3/z is not on the form a*z^n for n>=0).

The rest of the question is a separate question and should be in a different post.

  • Related