How to separate negative and positive terms in to two different expressions
1 回表示 (過去 30 日間)
古いコメントを表示
I am using symolic vavriables
syms a b c d f g
Where all syms variables are positive
and have, for example the following expression A
F=a- b*d+ g*c-a*c+ d*g
my actual expression is much longer but how can I separate the negative vs the positive terms and put them in say in x and y?
I appreciate any help .
Thank you!
0 件のコメント
採用された回答
Ameer Hamza
2020 年 12 月 3 日
Try this
syms a b c d f g
F = a - b*d + g*c - a*c + d*g;
parts = children(F);
parts = [parts{:}];
assume(symvar(parts)>0)
sgns = sign(parts);
assume(symvar(parts), 'clear')
x = parts(sgns==1);
y = parts(sgns==-1);
4 件のコメント
Ameer Hamza
2020 年 12 月 3 日
Yes, it seems something related to old release. It seems that children() does not return a cell array in your case.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Number Theory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!