How to simplify a symbolic equation, but still keep the denominator

1 回表示 (過去 30 日間)
Lu Zhao
Lu Zhao 2020 年 5 月 28 日
コメント済み: David Goodmanson 2020 年 6 月 1 日
Hi,
Here is a simplified equation for my problem: I would like to cancle "b" only at both side .(Euqation is in the code, "eqn1")
syms x y a b
eqn1 = b*(x/a + 1) == b*y/a; % This is the equation, I would like to cancel "b" at both side, and still keep "a" as denominator.
S=simplify(eqn1)
Results are:
S =
y == a + x | b == 0 % I want to get "(x/a+1)==y/a" instead.
Question: How can I enforce a rule to "simplify" command, so I can keep "a" as denominator, namely, I want to get : "(x/a+1)==y/a" ?

採用された回答

David Goodmanson
David Goodmanson 2020 年 5 月 30 日
Hi LZ
syms x y a b
eqn1 = b*(x/a + 1) == b*y/a; % This is the equation, I would like to cancel "b" at both side, and still keep "a" as denominator.
lhs = factor(b*(x/a + 1))
rhs = factor(b*y/a)
lhs(find(lhs==b)) = [];
rhs(find(rhs==b)) = [];
eqn2 = prod(lhs) == prod(rhs)
  2 件のコメント
Lu Zhao
Lu Zhao 2020 年 5 月 31 日
Thank you so much. It works and I learned a lot. I really appreciate your help.
David Goodmanson
David Goodmanson 2020 年 6 月 1 日
You're welcome, and I learned something as well. I had no idea if the product function would work, but it did.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by