How can I get the degree of a polynomial defined symbolically in MATLAB?
10 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2014 年 4 月 25 日
回答済み: MathWorks Support Team
2014 年 4 月 25 日
I defined a polynomial of several variables symbolically as follows:
syms x y z
P = x^4 + 3*x^2*y^2 - z^3 + y + 1
I can get the coefficients of the polynomial using the "coeffs" function. Now I would like to get the exponents of the polynomial but I can't seem to find a function to do that.
Is there a way to get the degree of a polynomial in the Symbolic Math Toolbox R2013b? I don't want to use a MuPAD notebook because all my code is written in MATLAB functions.
採用された回答
MathWorks Support Team
2014 年 4 月 25 日
As of release R2014a, there is no MATLAB function in the Symbolic Math Toolbox that can get the degree of a polynomial defined symbolically.
As a workaround you can use the MuPAD function "degree". To call the MuPAD engine from within MATLAB in order to use "degree", use the "feval" function as follows:
>> syms x y z
>> P = x^4 + 3*x^2*y^2 - z^3 + y + 1;
>> feval(symengine, 'degree', P)
ans =
4
To get the degree of "P" with respect to a specific variable, use the following:
>> syms x y z
>> P = x^4 + 3*x^2*y^2 - z^3 + y + 1;
>> feval(symengine, 'degree', P, y)
ans =
2
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!