coeffs of symbolic equation

1 次查看(过去 30 天)
Hi gusy
in this code the coeffes of x or y can extracted, but coeffes of x*y or x*y^2 can't obtain with coffes(), do you have any idea?
syms x y
z=x+2*x*y+4.*y+5*x*y^2;

采纳的回答

Paul
Paul 2021-5-12
编辑:Paul 2021-5-12
Is this what you're looking for:
syms x y
z=x+2*x*y+4.*y+5*x*y^2;
[cxy,t]=coeffs(z,[x y])
cxy = 
t = 
  3 个评论
Paul
Paul 2021-5-12
syms x y
z=x+2*x*y+4.*y+5*x*y^2;
[cxy,t]=coeffs(z,[x y])
cxy = 
t = 
cxy(logical(t == x*y^2))
ans = 
5
cxy(logical(t == y^2*x))
ans = 
5

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by