coeffs of symbolic equation

1 Ansicht (letzte 30 Tage)
ahmad ahmadi
ahmad ahmadi am 12 Mai 2021
Kommentiert: ahmad ahmadi am 12 Mai 2021
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;

Akzeptierte Antwort

Paul
Paul am 12 Mai 2021
Bearbeitet: Paul am 12 Mai 2021
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 Kommentare
Paul
Paul am 12 Mai 2021
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 am 12 Mai 2021
Thanks. It is answer

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by