Select specific coefficient from symbolic polynomial

12 ビュー (過去 30 日間)
Farid Salazar Wong
Farid Salazar Wong 2015 年 7 月 1 日
Given a symbolic polynomial in several variables I would like to pick the coefficient for a given monomial.
Ex: P(x,y,z)= 6*x^2*y + z*x- 5*x +7*x*y*z Let say I would like to find the coefficient of x*z in P(x,y,z) that is 1.
Or I could ask the coefficient of y in P(x,y,z) in this case I would obtain 0.
Or coefficient of x in P(x,y,z) I would obtain -5.
Is there a way to solve this?

採用された回答

Mischa Kim
Mischa Kim 2015 年 7 月 1 日
編集済み: Mischa Kim 2015 年 7 月 1 日
Farid, you can back out the subexpressions and the corresponding coefficients of the polynomial using coeffs
syms x y z P(x,y,z)
P(x,y,z) = 6*x^2*y + z*x- 5*x +7*x*y*z;
[c,t] = coeffs(P)
c(x, y, z) =
[ 6, 7, 1, -5]
t(x, y, z) =
[ x^2*y, x*y*z, x*z, x]
With this approach and a bit of logic you can write a function that returns the coefficient as stated in your question.
  1 件のコメント
Farid Salazar Wong
Farid Salazar Wong 2015 年 7 月 1 日
Thanks a lot. This helped me write my own function.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolynomials についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by