Rounding symbolic 4x4 matrix
Show older comments
Is there a way to round up the solution of T_06 to the nearest integer?
H=[0 0 1 -320;
0 -1 0 30;
1 0 0 -320;
0 0 0 1;]
t1 = 0; d1 = th1_; a1 = 0; alpha1 = 0;
t2 = th2_+pi; d2 = 0; a2 = L_; alpha2 = 0;
t3 = th3_-pi/2;d3 = 0; a3 = L_; alpha3= -pi/2;
t31 = 0; d31 =L_; a31 = 0; alpha31 = 0;
t4 = 0;d4 = L+th4_;a4 =-L_; alpha4 = pi;
t5 = th5_+pi;d5 = 0;a5 = L_; alpha5 = pi/2;
t51 = pi/2; d51= L_; a51 = 0; alpha51 = pi/2;
t52 = 0; d52 = L_; a52 =0; alpha52 = 0;
t6 = th6_;d6 = L_;a6 = 0; alpha6 = 0;
A_1_ = inTransMat(a_1,alpha_1,d_1,t_1);
A0_ = inTransMat(a0,alpha0,d0,t0);
%setting frame 0 as shown
A1 = inTransMat(a1,alpha1,d1,t1);
A2_ = inTransMat(a2,alpha2,d2,t2);
A3_ = inTransMat(a3,alpha3,d3,t3);
A31_= inTransMat (a31,alpha31,d31,t31);
A4_ = inTransMat(a4,alpha4,d4,t4);
A5_= inTransMat(a5,alpha5,d5,t5);
A51_= inTransMat (a51,alpha51,d51,t51);
A52_= inTransMat (a52,alpha52,d52,t52);
A6_= inTransMat(a6,alpha6,d6,t6);
T_ = A_1*A0*A1*A2_*A3_*A31*A4_*A5_*A51_*A52_*A6
T01_ = A_1*A0*A1;
T02_ = A_1*A0*A1*A2_;
T03_ = A_1*A0*A1*A2_*A3_*A31;
T04_ = A_1*A0*A1*A2_*A3_*A31*A4_;
T05_ = A_1*A0*A1*A2_*A3_*A4_*A5*A51_*A52_;
T_06= vpa(T_,2)
T_0611=simplify(vpa(T_06(1,1),2));
T_0612=simplify(vpa(T_06(1,2),2));
T_0613=simplify(vpa(T_06(1,3),2));
T_0614=simplify(vpa(T_06(1,4),2));
T_0621=simplify(vpa(T_06(2,1),2));
T_0622=simplify(vpa(T_06(2,2),2));
T_0623=simplify(vpa(T_06(2,3),2));
T_0624=simplify(vpa(T_06(2,4),2));
T_0631=simplify(vpa(T_06(3,1),2));
T_0632=simplify(vpa(T_06(3,2),2));
T_0633=simplify(vpa(T_06(3,3),2));
T_0634=simplify(vpa(T_06(3,4),2));
%alegrabi approach
eqn1= T_0611==H(1,1);
eqn2= T_0612==H(1,2);
eqn3= T_0613==H(1,3);
eqn4= T_0614==H(1,4);
eqn5= T_0621==H(2,1);
eqn6= T_0622==H(2,2);
eqn7= T_0623==H(2,3);
eqn8= T_0624 ==H(2,4);
eqn9= T_0631==H(3,2);
eqn10= T_0632==H(3,2);
eqn11= T_0633==H(3,3);
eqn12= T_0634==H(3,4);
%sol = solve([eqn1, eqn2, eqn3,eqn4,eqn5,eqn6,eqn7,eqn8,eqn9,eqn10,eqn11,eqn12], [th1_, th2_, th3_, th4_,th5_,th6_]);
%th1sol= sol.th1_
%th2sol= sol.th2_
%th3sol= sol.th3_
%th4sol= sol.th4_
%th5sol= sol.th5_
%th6sol= sol.th6_
function IT = inTransMat(a,b,c,d)
IT = [cos(d) -sin(d)*cos(b) sin(d)*sin(b) a*cos(d); sin(d) cos(d)*cos(b) -cos(d)*sin(b) a*sin(d); 0 sin(b) cos(b) c; 0 0 0 1];
end
function T = TransMat(a,b,c,d)
T = [cos(d) -sin(d)*cos(b) sin(d)*sin(b) a*cos(d); sin(d) cos(d)*cos(b) -cos(d)*sin(b) a*sin(d); 0 sin(b) cos(b) c; 0 0 0 1];
end
Accepted Answer
More Answers (0)
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!