how to make make matlab compute values of simple trignometric identities?

1 view (last 30 days)
cos(pi/2 + theta)= - sin(theta) ;
sin(pi + theta) = - sin(theta) ;
how do i compute these in MATLAB !
Here's my code ... (without identities its difficult to solve further)
syms L1 th1 L2 th2 L3 th3 th4 L5 th5;
a=[0 L2 L3 0 0];
alp=sym([(pi/2) 0 0 pi/2 0]);
d= [L1 0 0 0 L5];
th=sym([th1 th2+pi/2 th3-pi/2 th4+pi/2 th5]);
T=eye(4);
n= 5 ;
for i=1:n
switch i;
case 1
T01 =[cos(th(i)) -sin(th(i))*cos(alp(i)) sin(th(i))*sin(alp(i)) a(i)*cos(th(i));
sin(th(i)) cos(th(i))*cos(alp(i)) -sin(alp(i))*cos(th(i)) a(i)*sin(th(i));
0 sin(alp(i)) cos(alp(i)) d(i) ;
0 0 0 1]
case 2
T12 =[cos(th(i)) -sin(th(i))*cos(alp(i)) sin(th(i))*sin(alp(i)) a(i)*cos(th(i));
sin(th(i)) cos(th(i))*cos(alp(i)) -sin(alp(i))*cos(th(i)) a(i)*sin(th(i));
0 sin(alp(i)) cos(alp(i)) d(i) ;
0 0 0 1]
trignometr case 3
T23 =[cos(th(i)) -sin(th(i))*cos(alp(i)) sin(th(i))*sin(alp(i)) a(i)*cos(th(i));
sin(th(i)) cos(th(i))*cos(alp(i)) -sin(alp(i))*cos(th(i)) a(i)*sin(th(i));
0 sin(alp(i)) cos(alp(i)) d(i) ;
0 0 0 1]
case 4
T34 =[cos(th(i)) -sin(th(i))*cos(alp(i)) sin(th(i))*sin(alp(i)) a(i)*cos(th(i));
sin(th(i)) cos(th(i))*cos(alp(i)) -sin(alp(i))*cos(th(i)) a(i)*sin(th(i));
0 sin(alp(i)) cos(alp(i)) d(i) ;
0 0 0 1]
case 5
T45 =[cos(th(i)) -sin(th(i))*cos(alp(i)) sin(th(i))*sin(alp(i)) a(i)*cos(th(i));
sin(th(i)) cos(th(i))*cos(alp(i)) -sin(alp(i))*cos(th(i)) a(i)*sin(th(i));
0 sin(alp(i)) cos(alp(i)) d(i) ;
0 0 0 1]
end
end
T05=T01*T12*T23*T34*T45

Answers (2)

the cyclist
the cyclist on 6 Sep 2019
Do you mean you want to solve for theta, in the equation
cos(pi/2 + theta)= - sin(theta);
?
Use solve.
  2 Comments
Mayank Ghugretkar
Mayank Ghugretkar on 6 Sep 2019
yes
it computes for (pi + theta) but cant get it to compute cos(pi/2 + theta)= - sin(theta);
the cyclist
the cyclist on 6 Sep 2019
I'm unclear on what you mean by "can't get it to compute". Does it throw an error? It should just give theta=0 right?
(I don't have the symbolic math toolbox, so I can't try this myself.)

Sign in to comment.


Star Strider
Star Strider on 6 Sep 2019
If necessary, use the simplify function.
Example:
syms theta
Eq = sin(pi + theta)
Out = simplify(Eq, 'Steps',250)
This also works for your ‘T’ equations, although there is significant simplification by default, without a specific simplify call needed.

Community Treasure Hunt

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

Start Hunting!