How to Customize Sigma in subexpr()?

Let's say we have a formula below
syms k1 k2
eqn2 = (k1+k2+1)^2+(k1+k2+1)+1;
and put 'eqn2' into subexpr() function,
[EQN2, sigma] = subexpr(eqn2)
then the answer would be as follows:
EQN2 = sigma^2 + sigma + 1
sigma = k1 + k2 + 1
However, this time, I would like the sigma to be k1 + k2.
Could I customize the sigma as I want? If it's yes, how could I replace it?

 採用された回答

madhan ravi
madhan ravi 2019 年 4 月 17 日

1 投票

subs(eqn2,sigma,k1+k2)

1 件のコメント

Aoi Midori
Aoi Midori 2019 年 4 月 17 日
Thank you for your quick response. It worked!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

質問済み:

2019 年 4 月 17 日

コメント済み:

2019 年 4 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by