フィルターのクリア

Using coeffs to extract a matrix

10 ビュー (過去 30 日間)
Jonah Berean-Dutcher
Jonah Berean-Dutcher 2020 年 9 月 9 日
編集済み: Matt J 2020 年 9 月 9 日
I have a polynomial function of many symbolic variables, and I want to extract the 'coefficient matrix' from this polynomial. Every term in the polynomial has only two factors of these symbolic variables, i.e.
The coefficient matrix I want to extract is the one that would produce precisely this polynomial if I evaluated the vector-matrix-vector product:
where here x is a vector whose entries are all these symbolic variables, and Kis the coeffient matrix. In Mathematica, this is straightforward, there's a function called CoefficientArrays which performs exactly this operation. What is the best way to do this in Matlab? I have looked at the 'coeffs' function, but it doesn't appear to offer the same level of functionality as the Mathematica function I referenced.

採用された回答

Matt J
Matt J 2020 年 9 月 9 日
編集済み: Matt J 2020 年 9 月 9 日
The coefficient matrix I want to extract is the one that would produce precisely this polynomial if I evaluated the vector-matrix-vector product:
Such a K matrix is not unique, but the hessian() command,
will give a symmetric solution for K. E.g.,
>> syms x y z
>> P = 3*y^2 + x*y + 2*z*x;
>> K = hessian(P,[x,y,z])/2
K =
[ 0, 1/2, 1]
[ 1/2, 3, 0]
[ 1, 0, 0]
  1 件のコメント
Matt J
Matt J 2020 年 9 月 9 日
編集済み: Matt J 2020 年 9 月 9 日
If you want a solution for K that is upper triangular, you can transform the symmetric solution according to,
>> K=diag(diag(K))+2*triu(K,1)
K =
[ 0, 1, 2]
[ 0, 3, 0]
[ 0, 0, 0]

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by