Transform polynomium equation into multiple coefficient equations
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello
I want to match coefficients from 2 polynomiums:
syms x
syms a [3,1]
syms alpha beta gamma
eq = (1-alpha)*x^2 + (1-beta)*x + (1-gamma) == a1 *x^2 + 0*x + a3
Such that i get:
>>eq1 = 1-alpha == a1
>>eq2 = 1-beta == 0
>>eq3 = 1-gamma == a3
My current solution is:
cL = coeffs(lhs(eq),x,'all');
cR = coeffs(rhs(eq),x,'all');
new_eq = cL == cR
But that does not work when x is raised to a negative power:
eq = (1-alpha)*x^-2 + (1-beta)*x^-1 + (1-gamma) == a1 *x^-2 + 0*x^-1 + a3
I know that i can make a placeholder variable such that:
syms z
eq = subs(eq,x^-1,z)
cL = coeffs(lhs(eq),z,'all');
cR = coeffs(rhs(eq),z,'all');
new_eq = cL == cR
But that does not work if i have x to both positive and negative powers. And i am wondering if there is a command that can do all that for me instead
댓글 수: 0
답변 (0개)
참고 항목
카테고리
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!