How can i get the trigonometric function of cos and sin of a variable

2 vues (au cours des 30 derniers jours)
Arthur Ramirez
Arthur Ramirez le 31 Mar 2020
Hello everyone, i am creating a program which consists, that you have to insert the value of Theta, alfa, d, and r.
The program can solve multiplication of arrays which the user introduce as a number, or as a variable
With the multiplication of arrays when the user introduce numbers i didnt have problems, but when the user introduces the value of theta, alfa, d and r, in variables i got stucked.
This is what i´v been trying
if Art == 2
fprintf('\n \n')
T1 = input(' Introduce the value of Theta for row 1 = ', 's' )
A1 = input(' Introduce the value of alfa for row 1 = ', 's'')
d1 = input(' Introduce the value of d for row 1 = ', 's' )
r1 = input(' Introduce the value of r for row 1 = ', 's')
M1 = [cos(T1) -sin(T1) 0 d1; cos(A1)*sin(T1) cos(A1)*cos(T1) -sin(A1) -r1*sin(A1); sin(A1)*sin(T1) sin(A1)*cos(T1) cos(A1) r1*cos(A1); 0 0 0 1]
T2 = input(' Introduce the value of Theta for row 2 = ','s')
A2 = input(' Introduce the value of alfa for row 2 = ', 's')
d2 = input(' Introduce the value of d for row 2 = ', 's')
r2 = input(' Introduce the value of r for row 2= ', 's')
M2 = [cos(T2) -sin(T2) 0 d2; cos(A2)*sin(T2) cos(A2)*cos(T2) -sin(A2) -r2*sin(A2); sin(A2)*sin(T2) sin(A2)*cos(T2) cos(A2) r2*cos(A2); 0 0 0 1]
pause(2)
Res = M1*M2
pause(3)
disp(' See ya =)')
break

Réponses (1)

David Hill
David Hill le 31 Mar 2020
Why are the users not entering numbers instead of character arrays?
T1 = input('Introduce the value of Theta for row 1 = ');
  7 commentaires
David Hill
David Hill le 1 Avr 2020
It will work no matter what the user introduces. Give it a try!
Arthur Ramirez
Arthur Ramirez le 1 Avr 2020
Actually it worked thank you so much David!
Have a great night!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Discrete Math dans Help Center et File Exchange

Produits


Version

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by