How to Make Complex Symbolic Variable Change?

1 回表示 (過去 30 日間)
Giulio Cesare Mastrocinque Santo
Giulio Cesare Mastrocinque Santo 2018 年 11 月 24 日
編集済み: madhan ravi 2018 年 11 月 24 日
Hello! Imagine I have a very long equation with many variables, like the example bellow
eq = 0.001*(wr + wl) + 2*z + 1.5*z == -2wp
How can I force matlab to make the following change of variable:
Y = 0.1*(wr + wl) ?
I mean, I need matlab to group the equation (eq) into 0.1*(wr + wl) and replace those terms by Y. In the example above, the result should be:
eq = 0.01*Y + 2*z + 1.5*z == -2wp
Thanks a lot!

採用された回答

madhan ravi
madhan ravi 2018 年 11 月 24 日
編集済み: madhan ravi 2018 年 11 月 24 日
>> syms wr wl z wp Y
eq = 0.001*(wr + wl) + 2*z + 1.5*z == -2*wp
eq=subs(eq,0.001*(wr+wl),0.01*Y)
eq =
wl/1000 + wr/1000 + (7*z)/2 == -2*wp
eq =
Y/100 + (7*z)/2 == -2*wp
>> vpa(eq)
ans =
0.01*Y + 3.5*z == -2.0*wp
>>
  3 件のコメント
Giulio Cesare Mastrocinque Santo
Giulio Cesare Mastrocinque Santo 2018 年 11 月 24 日
Your idead pointed me to the right solution! Thanks a lot! I just need to do the opposit:
syms wr wl z wp Y x
eq = 0.001*(wr + wl) + sin(2*x)*2.5*(wr + wl)^2 + 0.9*(wr + wl)^2 + 2*z + 1.5*z == -2*wp
subs(eq,(wr+wl),Y/0.1)
madhan ravi
madhan ravi 2018 年 11 月 24 日
編集済み: madhan ravi 2018 年 11 月 24 日
Anytime :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunctional Programming についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by