How to plot sym array in given value
1 次查看(过去 30 天)
显示 更早的评论
syms a1 a2 a4 a5;
d1=100;d2=250;d3=50;d4=250;d5=100;
% define transformation matrix
T_01=[sin(a1) 0 cos(a1) 0; -cos(a1) 0 sin(a1) 0; 0 -1 0 d1; 0 0 0 1];
T_12=[cos(a2) 0 sin(a2) d2*cos(a2); sin(a2) 0 -cos(a2) d2*sin(a2); 0 1 0 0; 0 0 0 1];
T_23=[-1 0 0 0; 0 0 1 0; 0 1 0 d3; 0 0 0 1];
T_34=[cos(a4) -sin(a4) 0 d4*cos(a4); sin(a4) cos(a4) 0 d4*sin(a4); 0 0 1 0; 0 0 0 1];
T_4H=[cos(a5) -sin(a5) 0 d5*cos(a5); sin(a5) cos(a5) 0 d5*sin(a5); 0 0 1 0; 0 0 0 1];
% Calculate center of E.E. frame
T_0H=T_01*T_12*T_23*T_34*T_4H;
P = transpose([0 0 0 1]);
P1_0=T_0H*P;
% give value
a1 = 0:pi/1000:pi/2;
a2 = 0:-pi/500:-pi;
a4 = 0:pi/1000:pi/2;
a5 = 0:-pi/1000:-pi/2;
%plot 501 point
for i=1:1:501
a1(i);a2(i);a4(i);a5(i);
plot3(P1_0(1),P1_0(2),P1_0(3));
end
I want to cnovert P1_0 to 4x1x501 double array, so can plot path in 3d space. How can i do that? Thank for your help.
0 个评论
采纳的回答
Walter Roberson
2023-10-19
syms a1 a2 a4 a5;
d1=100;d2=250;d3=50;d4=250;d5=100;
% define transformation matrix
T_01=[sin(a1) 0 cos(a1) 0; -cos(a1) 0 sin(a1) 0; 0 -1 0 d1; 0 0 0 1];
T_12=[cos(a2) 0 sin(a2) d2*cos(a2); sin(a2) 0 -cos(a2) d2*sin(a2); 0 1 0 0; 0 0 0 1];
T_23=[-1 0 0 0; 0 0 1 0; 0 1 0 d3; 0 0 0 1];
T_34=[cos(a4) -sin(a4) 0 d4*cos(a4); sin(a4) cos(a4) 0 d4*sin(a4); 0 0 1 0; 0 0 0 1];
T_4H=[cos(a5) -sin(a5) 0 d5*cos(a5); sin(a5) cos(a5) 0 d5*sin(a5); 0 0 1 0; 0 0 0 1];
% Calculate center of E.E. frame
T_0H=T_01*T_12*T_23*T_34*T_4H;
P = transpose([0 0 0 1]);
P1_0=T_0H*P;
% give value
A1 = 0:pi/1000:pi/2;
A2 = 0:-pi/500:-pi;
A4 = 0:pi/1000:pi/2;
A5 = 0:-pi/1000:-pi/2;
ssP1_0 = P1_0(1:3);
vars = [a1, a2, a4, a5];
%plot 501 point
for i=1:1:501
temp = double(subs(ssP1_0, vars, [A1(i), A2(i), A4(i), A5(i)]));
plot3(temp(1), temp(2), temp(3), '.');
hold on
end
2 个评论
Walter Roberson
2023-10-19
syms a1 a2 a4 a5;
d1=100;d2=250;d3=50;d4=250;d5=100;
% define transformation matrix
T_01=[sin(a1) 0 cos(a1) 0; -cos(a1) 0 sin(a1) 0; 0 -1 0 d1; 0 0 0 1];
T_12=[cos(a2) 0 sin(a2) d2*cos(a2); sin(a2) 0 -cos(a2) d2*sin(a2); 0 1 0 0; 0 0 0 1];
T_23=[-1 0 0 0; 0 0 1 0; 0 1 0 d3; 0 0 0 1];
T_34=[cos(a4) -sin(a4) 0 d4*cos(a4); sin(a4) cos(a4) 0 d4*sin(a4); 0 0 1 0; 0 0 0 1];
T_4H=[cos(a5) -sin(a5) 0 d5*cos(a5); sin(a5) cos(a5) 0 d5*sin(a5); 0 0 1 0; 0 0 0 1];
% Calculate center of E.E. frame
T_0H=T_01*T_12*T_23*T_34*T_4H;
P = transpose([0 0 0 1]);
P1_0=T_0H*P;
% give value
A1 = 0:pi/1000:pi/2;
A2 = 0:-pi/500:-pi;
A4 = 0:pi/1000:pi/2;
A5 = 0:-pi/1000:-pi/2;
ssP1_0 = P1_0(1:3);
vars = {a1, a2, a4, a5};
%plot 501 point
temp = double(subs(ssP1_0, vars, {A1, A2, A4, A5}));
plot3(temp(1,:), temp(2,:), temp(3,:));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!