How can I get the degree of a polynomial defined symbolically in MATLAB?

10 次查看(过去 30 天)
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
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 个)

产品


版本

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by