Borrar filtros
Borrar filtros

How do I get these two equations to work in scenarious like this

2 visualizaciones (últimos 30 días)
Rohan Dey
Rohan Dey el 27 de Oct. de 2022
Respondida: Torsten el 27 de Oct. de 2022
How do I get these two equations to work when the equations are in the problem but not directly in the problem for the way they are worded. (sorry i have bad english)
syms theta1 theta2 theta3 theta4 theta5 theta6
syms c23 s23
cos23 = (cos(theta2)*cos(theta3))-(sin(theta2)*sin(theta3));
sin23 = (cos(theta2)*sin(theta3))+(sin(theta2)*cos(theta3));
T_04_INV = inv(T_01*T_12*T_23*T_34)
T_04_INV = subs(T_04_INV,[c1 s1 c2 s2 c3 s3 c4 s4], [cos(theta1) sin(theta1) cos(theta2) sin(theta2) cos(theta3) sin(theta3) cos(theta4) sin(theta4)])
T_04_INV = simplify(T_04_INV)
T_04_INV = subs(T_04_INV,[cos(theta1) sin(theta1) cos(theta2) sin(theta2) cos(theta3) sin(theta3) cos(theta4) sin(theta4) cos(theta2 + theta3) sin(theta2 + theta3)], [c1 s1 c2 s2 c3 s3 c4 s4 c23 s23])
where
T_04_INV =
[s1*s4 - c1*c4*s2*s3 + c1*c2*c3*c4, c2*c3*c4*s1 - c4*s1*s2*s3 - c1*s4, -c4*s23, d3*s4 - a3*c4 - a2*c3*c4]
[c4*s1 + c1*s2*s3*s4 - c1*c2*c3*s4, s1*s2*s3*s4 - c2*c3*s1*s4 - c1*c4, s4*s23, c4*d3 + a3*s4 + a2*c3*s4]
[ -c1*s23, -s1*s23, -c23, a2*s3 - d4]
[ 0, 0, 0, 1]
The bottom three (3,1) (3,2) (3,3) positions are working, simplyfying into c23 and s23. But they other lines are not even though they have (cos(theta2)*cos(theta3))-(sin(theta2)*sin(theta3)) and (cos(theta2)*sin(theta3))+(sin(theta2)*cos(theta3)) in there equations (just not directly)
How do I fix this so all equations simplify for c23 and s23?

Respuestas (1)

Torsten
Torsten el 27 de Oct. de 2022
As far as I know, MATLAB won't perform algebraic manipulations before substituting variables or algebraic expressions.
As an example see
syms a b c
x = a^2 + 2*a*b + b^2;
v = subs(x,a+b,c)
v = 
x = (a+b)^2;
v = subs(x,a+b,c)
v = 

Categorías

Más información sobre Numbers and Precision en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by