How can I get the degree of a polynomial defined symbolically in MATLAB?
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 25 Apr 2014
Risposto: MathWorks Support Team
il 25 Apr 2014
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.
Risposta accettata
MathWorks Support Team
il 25 Apr 2014
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 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!