How to solve a symbolic script expression within a cell and assign the answer to a new variable

1 次查看(过去 30 天)
I have a 1x1 symbolic object (X) containing the following symbolic expression:
int(T - 2*t, t, 0, T)
I want to create a new variable (a0) that is simply the result of the above integration.
I can obtain the result by calling out the symbolic expression in the command window, copying and pasting it back into the command window and hitting enter (answer = 0).
How do I do this without copy and pasting?
Thanks

采纳的回答

Star Strider
Star Strider 2014-9-28
编辑:Star Strider 2014-9-28
Assign it to a variable:
syms t T
a0 = int(T - 2*t, t, 0, T)
produces:
a0 =
0
  9 个评论
Nate
Nate 2014-9-28
Strange - I have R2014a. A0 returns the long form with int() for me, whereas eval(A0) returns T^2/2. All good, thanks

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by