How to separate positive and negative symbolic variables of an equation to the left and right sides of the equation in MATLAB?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ehsan
am 28 Nov. 2015
Kommentiert: ehsan
am 30 Nov. 2015
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 29 Nov. 2015
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!