Using operators for syms

2 ビュー (過去 30 日間)
Majid kh
Majid kh 2019 年 2 月 15 日
回答済み: Ayush Modi 2024 年 8 月 30 日
Hi dear, I execute this program:
syms S;
A=1/(S+1);
B=2/(S+3);
Result=A+B
but result is:
Result =
1/(S + 1) + 2/(S + 3)
How can i change result to become format like below?
Result =
(3*S)/( S^2+4*S+3)

回答 (1 件)

Ayush Modi
Ayush Modi 2024 年 8 月 30 日
Hi Majid,
Please note that; with the given values, the result of adding A and B should be -
(3*S) + 5/( S^2+4*S+3)
Assuming that is the desired result, you can use the "collect" function to simplify the equation.
syms S;
A=1/(S+1);
B=2/(S+3);
Result=A+B
Result = 
Result = simplify(Result)
Result = 
Result = collect(Result, S)
Result = 
Refer to the following MathWorks documentation for more details on "collect" function:

カテゴリ

Help Center および File ExchangeSymbolic Variables, Expressions, Functions, and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by