How to separate positive and negative symbolic variables of an equation to the left and right sides of the equation in MATLAB?
조회 수: 1 (최근 30일)
이전 댓글 표시
for example we have this equation : 3*a - 2*b + 5*c - d = 0
First I need to separate positive and negative variables to both side of equation: 3*a + 5*c = 2*b + d
and then take only the coefficient of each symbolic variables: 3 + 5 = 2 + 1
Thank you
댓글 수: 0
채택된 답변
Walter Roberson
2015년 11월 29일
syms a b c d
eq = 3*a - 2*b + 5*c - d;
constants = subs( children(eq), {a b c d}, {1 1 1 1} );
pospart = constants(constants>0));
negpart = -constants(constants<0));
sum(postpart) == sum(negpart) %this will usually be false
추가 답변 (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!