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. "
댓글 수: 0
채택된 답변
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]
댓글 수: 2
Ozgur
2015년 2월 18일
I do not know if you noticed, but this code above doesn't result as [2,3,4]. It results equation itself...
추가 답변 (1개)
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 Center 및 File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!