coeffs - Coefficients of multivariate polynomial

Syntax

C = coeffs(p)
C = coeffs(p,x)
[C,T] = coeffs(p,x)

Description

C = coeffs(p) returns the coefficients of the polynomial p with respect to all the indeterminates of p.

C = coeffs(p,x) returns the coefficients of the polynomial p with respect to x.

[C,T] = coeffs(p,x) also returns an expression sequence of the terms of p. There is a one-to-one correspondence between the coefficients and the terms of p.

Examples

syms x
t = 2 + (3 + 4*log(x))^2 - 5*log(x);
coeffs(expand(t)) = [ 11, 19, 16]      

syms a b c x
y = a + b*sin(x) + c*sin(2*x)
coeffs(y,sin(x)) = [a+c*sin(2*x), b]
coeffs(expand(y),sin(x)) = [a, b+2*c*cos(x)]

syms x y
z = 3*x^2*y^2 + 5*x*y^3
coeffs(z) = [3, 5] 
coeffs(z,x) = [5*y^3, 3*y^2]
[c,t] = coeffs(z,y) returns c = [3*x^2, 5*x], t = [y^2, y^3]

See Also

sym2poly

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS