subs(): Unexpected simplification behaviour

1 回表示 (過去 30 日間)
Thomas Bauer
Thomas Bauer 2015 年 4 月 27 日
回答済み: Philip Caplan 2015 年 4 月 29 日
syms Gr Ra Ri A B Gr1 Gr2 c d
Gr = 2*c*(Ra^2 - Ri^2) - d*(Ra^4 - Ri^4)/2;
Gr1 = subs(Gr, [c*(Ra^2 - Ri^2), -d*(Ra^4 - Ri^4)/2], [A, B])
Gr2 = subs(Gr, [c*(Ra^2 - Ri^2), d*(Ra^4 - Ri^4)/2], [A, B])
returns
Gr1 =
2*A + B
Gr2 =
2*A - (d*(Ra^4 - Ri^4))/2
Is there a way to convince MATLAB to return
Gr2 = 2*A - B
in the second case without workarounds? Of course, workarounds like
Gr2 = subs(Gr, [c*(Ra^2 - Ri^2), -d*(Ra^4 - Ri^4)/2], [A, -B])
or
Gr1 = subs(Gr, [(Ra^2 - Ri^2),(Ra^4 - Ri^4)], [A/c,-2*B/d])
Gr2 = subs(Gr, [(Ra^2 - Ri^2),(Ra^4 - Ri^4)], [A/c,2*B/d])
will return the desired result, but I have a much more complex expression to substitute and can't work with this subs()-behaviour. I would have expected MATLAB to automatically simplify the respecive equations.

採用された回答

Philip Caplan
Philip Caplan 2015 年 4 月 29 日
As you mentioned, "subs" should return "Gr2 = 2*A -B". I have notified the development team here at MathWorks about this behavior and they will hopefully resolve this in a future release.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation Models についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by