Replacing a symbolic time-varying variable with a numerical value
I have the following rotation matrix and its derivative with respect to time. The rotation matrix contains three angles a1,a2, and a3.For each angle, I would like to substitute a(t) with its numerical value with keeping its derivative (i.e. diff(a(t), t)) as symbolic variable.
Rsb =
[cos(a1(t))*cos(a2(t) + a3(t)), -sin(a1(t)), -cos(a1(t))*sin(a2(t) + a3(t))]
[sin(a1(t))*cos(a2(t) + a3(t)), cos(a1(t)), -sin(a1(t))*sin(a2(t) + a3(t))]
[ sin(a2(t) + a3(t)), 0, cos(a2(t) + a3(t))]
dRsb =
[- sin(a1(t))*cos(a2(t) + a3(t))*diff(a1(t), t) - cos(a1(t))*sin(a2(t) + a3(t))*(diff(a2(t), t) + diff(a3(t), t)), -cos(a1(t))*diff(a1(t), t), sin(a1(t))*sin(a2(t) + a3(t))*diff(a1(t), t) - cos(a1(t))*cos(a2(t) + a3(t))*(diff(a2(t), t) + diff(a3(t), t))]
[ cos(a1(t))*cos(a2(t) + a3(t))*diff(a1(t), t) - sin(a1(t))*sin(a2(t) + a3(t))*(diff(a2(t), t) + diff(a3(t), t)), -sin(a1(t))*diff(a1(t), t), - cos(a1(t))*sin(a2(t) + a3(t))*diff(a1(t), t) - sin(a1(t))*cos(a2(t) + a3(t))*(diff(a2(t), t) + diff(a3(t), t))]
[ cos(a2(t) + a3(t))*(diff(a2(t), t) + diff(a3(t), t)), 0, -sin(a2(t) + a3(t))*(diff(a2(t), t) + diff(a3(t), t))]
I've tried this solution but it sets the derivative to zero as well.
subs(dRsb, {a1(t),a2(t),a3(t)}, {0,0,0})
You can see when angles are zeros, dRsb(3,1) should equal to (diff(a2(t), t) + diff(a3(t), t))
. any suggestions.
If you're content with choosing a specific value for t (e.g. t=0), then the following should work.
subs(subs(dRsb,t,0), {a1(0),a2(0),a3(0)}, {0,0,0})
Here's a "hack" to get the behavior that you want.
syms s
subs(s,subs(subs(dRsb,t,s-1), {a1(s-1),a2(s-1),a3(s-1)}, {0,0,0}),t+1)