syms c A(t) v(t)
A(t) =
0
c*sin(tt(t))
c*cos(tt(t))
How I can get X = A(2) = c*sin(tt(t));
(the function at second row)? If I type A(2)
, the result will be as below (it substitutes a constant for the function, which is not my desire):
>> A(2)
ans =
0
c*sin(tt(2))
c*cos(tt(2))
The problem is that you've defined A
as a symbolic function (symfun
), not as an array of symbolic expressions. Instead:
syms c A tt(t)
A = [0;
c*sin(tt(t));
c*sin(tt(t))];
Now A(2)
will return c*sin(tt(t))
.
Alternatively, if you can't change the definition of A(t)
, you'll need to assign it to an intermediate variable to convert it to an array of symbolic expressions:
syms c A(t) tt(t)
A(t) = [0;
c*sin(tt(t));
c*cos(tt(t))];
B = A(t);
Then, B(2)
will return c*sin(tt(t))
. You can also use formula
to extract the underlying expressions:
B = formula(A):