How to change a Function by a Variable

12 ビュー (過去 30 日間)
ercan duzgun
ercan duzgun 2021 年 1 月 10 日
コメント済み: ercan duzgun 2021 年 1 月 10 日
How can I change a MATLAB function with a variable? (They are symbolic equations.)
Assume that I have an equation of "A*sin(phi)+B*cos(phi)". I want to replace "sin(phi)" by "2*x/(1+x^2)" , and "cos(phi)" should by replaced by "2*x/(1+x^2)" ? (Notice that x=tan (phi/2) , therefore sin(phi)=2*x/(1+x^2), and cos(phi)=2*x/(1+x^2) ) .
The final symboic equation should look :
"A*2*x/(1+x^2) + B*2*x/(1+x^2)"
syms A B phi x
equation_current=A*sin(phi)+B*cos(phi)
% ??? Some unknown operations ???
equation_new=A*2*x/(1+x^2) + B*2*x/(1+x^2)

採用された回答

Mischa Kim
Mischa Kim 2021 年 1 月 10 日
編集済み: Mischa Kim 2021 年 1 月 10 日
Ercan, here you go, for the first term:
syms phi x A B
eq = A*sin(phi) + B*cos(phi)
eq = subs(eq,sin(phi),2*x/(1+x^2))
  1 件のコメント
ercan duzgun
ercan duzgun 2021 年 1 月 10 日
Dear Mischa Kim,
Thank you very much. It works. I wasn't aware of this command. Thank you.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by