Making a transformation matrix in matrix format

Hi, I've a matrix shows below
syms th d alph l
A = [cos(th) -cos(alph)*sin(th) sin(alph)*sin(th) l*cos(th);
sin(th) cos(alph)*cos(th) -sin(alph)*cos(th) l*sin(th);
0 sin(alph) cos(alph) d;
0 0 0 1]
i end up getting 4 matrices
A =
[cos(th), -cos(alph)*sin(th), sin(alph)*sin(th), l*cos(th)]
[sin(th), cos(alph)*cos(th), -sin(alph)*cos(th), l*sin(th)]
[ 0, sin(alph), cos(alph), d]
[ 0, 0, 0, 1]
but I want it in one matrix format, what can I do with it?

1 comentario

syms th d alph l
A = [ cos(th) -cos(alph)*sin(th) sin(alph)*sin(th) l*cos(th);
sin(th) cos(alph)*cos(th) -sin(alph)*cos(th) l*sin(th);
0 sin(alph) cos(alph) d;
0 0 0 1 ];
syms th1
A1 = subs(A,{l,alph,d,th},{0,pi/2,20,th1})
or I use subs numbers in the the matrix, I end uo getting this 4 matrices
A1 =
[cos(th1), 0, sin(th1), 0]
[sin(th1), 0, -cos(th1), 0]
[ 0, 1, 0, 20]
[ 0, 0, 0, 1]
I want to get it in one matrix like below
A1 =
cos(th1), 0, sin(th1), 0;
sin(th1), 0, -cos(th1), 0;
0, 1, 0, 20;
0, 0, 0, 1;
Thank you!

Iniciar sesión para comentar.

 Respuesta aceptada

Paul
Paul el 30 de Mzo. de 2021
You're not getting 4, 1 x 4 matrices. It just looks like that because of the formatting to the diplay.
>> syms th d alph l
A = [ cos(th) -cos(alph)*sin(th) sin(alph)*sin(th) l*cos(th);
sin(th) cos(alph)*cos(th) -sin(alph)*cos(th) l*sin(th);
0 sin(alph) cos(alph) d;
0 0 0 1 ];
>> size(A)
ans =
4 4
As shown, A is, in fact, one 4 x 4 sym matrix.

5 comentarios

Thank you for your reply.
I want to get one 4x4 matrix. (like below)
A = cos(th) -cos(alph)*sin(th) sin(alph)*sin(th) l*cos(th)
sin(th) cos(alph)*cos(th) -sin(alph)*cos(th) l*sin(th)
0 sin(alph) cos(alph) d
0 0 0 1
but in fact, I getting four 1x4 matrices.
A =
[cos(th), -cos(alph)*sin(th), sin(alph)*sin(th), l*cos(th)]
[sin(th), cos(alph)*cos(th), -sin(alph)*cos(th), l*sin(th)]
[ 0, sin(alph), cos(alph), d]
[ 0, 0, 0, 1]
Paul
Paul el 31 de Mzo. de 2021
As I showed, A is a 4x4 matrix. What do you get for
>> size(A)
C K Chan
C K Chan el 31 de Mzo. de 2021
I get 4x4 for A.
Paul
Paul el 31 de Mzo. de 2021
So everything works as you need it to work?
C K Chan
C K Chan el 3 de Abr. de 2021
Thanks a lot.
I fixed it.

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 30 de Mzo. de 2021

Comentada:

el 3 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by