coeffs of symbolic equation

조회 수: 1 (최근 30일)
ahmad ahmadi
ahmad ahmadi 2021년 5월 12일
댓글: ahmad ahmadi 2021년 5월 12일
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
ahmad ahmadi
ahmad ahmadi 2021년 5월 12일
Thanks. It is answer

댓글을 달려면 로그인하십시오.

추가 답변 (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