Let us say we have this big expression:
t=m2*l2^2*(thetadotdot1+thetadotdot2)+m2*l1*l2*cos(theta2)*(2*thetadotdot1+thetadotdot2)+(m1+m2)*l1^2*thetadotdot1-m2*l1*l2*sin(theta2)*(thetadot2^2)-2*m2*l1*l2*sin(theta2)*(thetadot1*thetadot2)+m2*l2*g*cos(theta1+theta2)+(m1+m2)*l1*g*cos(theta1);
And I want all terms multiplied by thetadot1 and thetadot2 out but Matlab doesnt seem to be able to do that.
The output i seek is (from a textbook):
-m2*l1*l2*sin(theta2)*thetadot2^2-2*m2*l1*l2*sin(theta2)*thetadot1*thetadot2
The first term (-m2*l1*l2*sin(theta2)*thetadot2^2) and the subsequent one are both from the original but we have only taken what we wish i.e all terms with thetadot1 and thetadot2.
I have used
n=1; p=feval(symengine, 'coeff', t, thetadot1,n)
and my output for the first part is.
-2*l1*l2*m2*thetadot2*sin(theta2)
So I have lost the exponent. I am hoping someone can help me troubleshoot this. I need to find a universial method as i need to implement it on a 40 microsoft word page long formula
Best Answer