Find coefficient in symbolic expression or matrix in matlab

1 次查看(过去 30 天)
I have the equation below: 2*x+3*y+4*z I want to separate the coefficients from syms. I want a function that its result from my equation be [2 3 4] "some times maybe my coefficients be a symbol too. "

采纳的回答

Star Strider
Star Strider 2012-10-27
编辑:Star Strider 2012-10-27
This should do what you want:
syms x y z
f = 2*x+3*y+4*z
cf = coeffs(f, [z y x])
It results in:
cf =
[ 2, 3, 4]
See the coeffs documentation for more information.

更多回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2012-10-27
编辑:Azzi Abdelmalek 2012-10-27
syms x y z
u=2*x+3*y+4*z
[c,t] = coeffs(u, [x y z])

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by