How can I take the time derivative of a multi-variable symbolic function?

6 views (last 30 days)
Here is come of the code im currently working with. Sorry about the absolutely massive Texp function, I had it all in vectors that reduced the volume significantly but then ran into other issues. I have all the input variables defined as symbols, and the angles (theta, phi and psi) are all functions of time (t). These represent angular orientation, and the related velocities and accelerations are defined as derivatives of the position. I want to take the time derivative (d/dt) of the derivative of T with respect to thetad. So d/dt(dTexp/d thetad). I get a symbolic expression for the first two diff calls, but the last diff call yields 0, likely because there is no "t" directly present. I can provide the complete .m file if needed, there are some undefined variables in the section i pasted here that might seem confusing but I have defined everything and get no errors when I run the script. What am I doing wrong?
%theta = about z, phi = about y, psi = about x: position
syms theta(t) phi(t) psi(t) thetad(t) thetadd(t) phid(t) phidd(t) psid(t) psidd(t)
%angular velocity
thetad = sym('diff(theta, t)'); phid = sym('diff(phi, t)'); psid = sym('diff(psi, t)');
%angular acceleration
thetadd = sym('diff(thetad, t)'); phidd = sym('diff(phid, t)'); psidd = sym('diff(psid, t)');
syms Texp(m, l, theta, thetad, thetadd, phi, phid, phidd, psi, psid, psidd, Jtheta, Jphi, Jpsi, F1x, F1y, F1z, F2x, F2y, F2z)
Texp = .5.*m*(((-l/2).*(sin(theta).*cos(phi).*thetad + cos(theta).*sin(phi).*phid).^2) + (((l/2).*cos(theta).*thetad).^2) + (((l/2).*((cos(phi).*cos(theta).*phid) - (sin(phi).*sin(theta).*thetad))).^2)) + .5.*(Jtheta.*(thetad.^2) + Jphi.*(phid.^2) + Jpsi.*(psid.^2)) + .5.*(((F1(1)+F2(1)).*((-l/2).*(sin(theta).*cos(phi).*thetad + cos(theta).*sin(phi).*phid).^2)./((-l/2).*((cos(theta).*cos(phi).*((thetad.^2)+(phid.^2))) - (2.*sin(theta).*sin(phi).*thetad.*phid) + (sin(theta).*cos(phi).*thetadd) + (cos(theta).*sin(phi).*phidd)))) + ((F1(2)+F2(2)).*(((l/2).*cos(theta).*thetad).^2)./((l/2).*((cos(theta).*thetadd) - (sin(theta).*(thetad.^2))))) + ((F1(3)+F2(3)).*(((l/2).*((cos(phi).*cos(theta).*phid) - (sin(phi).*sin(theta).*thetad))).^2)./((-l/2).*((sin(phi).*cos(theta).*((phid.^2)+(thetad.^2))) + (2.*cos(phi).*sin(theta).*phid.*thetad) - (cos(phi).*cos(theta).*phidd) + (sin(phi).*sin(theta).*thetadd)))));
syms delT_delTheta delT_delThetad d_dt_delThetad
delT_delTheta = diff(Texp, 'theta')
delT_delThetad = diff(Texp, 'thetad')
d_dt_delThetad = diff(delT_delThetad, 't') *****
The starred diff call is the one I'm having trouble with. I get symbolic expressions from the first two calls but 0 for the third.

Answers (0)

Community Treasure Hunt

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

Start Hunting!