How I explicit one function in terms of another function using symbolic?
古いコメントを表示
syms t T
syms a(t) c0(t) d(t)
I(t) = a(0)*c0(t) + a(2)*c0(t - 2*T) + a(4)*c0(t - 4*T)
Q(t) = a(1)*c0(t - T) + a(3)*c0(t - 3*T) + a(5)*c0(t - 5*T)
s(t) = I(t)*cos(t) - Q(t)*sin(t)
Suppose I wish to express s(t) in terms of I(t) and Q(t). That is, I wish to see
s(t) = I(t)*cos(t) - Q(t)*sin(t)
in the command window. How i do that?
OBS: I don't wanna substitute the awser by I(t) and Q(t). I just wanna explicit I(t) and Q(t) in my expression.
(I know, it's don't seems productive. But in longs expressions, it do).
8 件のコメント
darova
2019 年 9 月 3 日
Can't you just ype in Command Window:
I(t)*cos(t) - Q(t)*sin(t)
Rubem Pacelli
2019 年 9 月 5 日
darova
2019 年 9 月 5 日
There is pretty() function. What about it?
Walter Roberson
2019 年 9 月 5 日
There is a very obscure way of doing it, but unless you take obscure special steps, when you try to display the result, your symbolic engine would be reset. You have to use MuPAD facilities that are not recognized by the MATLAB level.
Rubem Pacelli
2019 年 11 月 7 日
編集済み: Rubem Pacelli
2019 年 11 月 7 日
Rubem Pacelli
2019 年 11 月 7 日
Walter Roberson
2019 年 11 月 7 日
You would need to evalin(symengine) or feval(symengine) using hold() constructs on the symbols I(t) and Q(t) to prevent them from being evaluated to the definitions you gave for the functions. However, most of the time at least one mupad eval() operation is done on your behalf, often at least three of them, and that would replace the symbols with the contents. You would need to experiment at the feval() or evalin() level to find the perfect number of nested hold() operations to put around the symbols so that the mupad print operation applied to the expression removed all of hold objects without execution of the symbols to their content while still permitting the expression to be evaluated more fully to get the expanded form when needed.
It would be a heck of a lot easier if you were willing to live with a printed representation that did not use exactly the same symbol names, and then used subs() when you wanted to expand.
Rubem Pacelli
2020 年 1 月 4 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Common Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!