# How to use poly2list for specific variables?

4 vues (au cours des 30 derniers jours)
Dan Li le 30 Nov 2017
Modifié(e) : Karan Gill le 5 Déc 2017
Hi there,
In the example 2 of the help for 'poly2list' https://www.mathworks.com/help/symbolic/mupad_ref/poly2list.html?s_tid=srchtitle, it shows as follows:
In this example the polynomial is bivariate, thus exponent vectors are returned:
poly2list((x*(y + 1))^2, [x, y])
How to use this in MATLAB? I tried feval but it shows error:
>> syms x y
>> feval(symengine, 'poly2list', (x*(y + 1))^2, [x, y])
The number of arguments is incorrect.
Thanks,
Dan
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Walter Roberson le 30 Nov 2017
symLIST = @(varargin)feval(symengine,'DOM_LIST',varargin{:});
feval(symengine,'poly2list', (x*(y + 1))^2, symLIST(x,y))
##### 5 commentairesAfficher 3 commentaires plus anciensMasquer 3 commentaires plus anciens
Walter Roberson le 30 Nov 2017
varcell = num2cell(X);
feval(symengine,'poly2list', (x*(y + 1))^2, symLIST(varcell{:}))
Dan Li le 30 Nov 2017
Thanks you very much! This really helps me a lot!

Connectez-vous pour commenter.

### Plus de réponses (1)

Karan Gill le 30 Nov 2017
Modifié(e) : Karan Gill le 5 Déc 2017
In general, I don't recommend using MuPAD commands, as the note at the top says.
>> syms x y
p = (x*(y + 1))^2;
[C,T] = coeffs(p,[x y]) % C = coeffs, T = terms
C =
[ 1, 2, 1]
T =
[ x^2*y^2, x^2*y, x^2]
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Dan Li le 30 Nov 2017
I also want extract the power value of every variable in every monomial. Is there any way to convert the x^2*y^2 to [2, 2]?
Thanks,
Dan

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Common Operations dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by