Why is my plot not showing?

조회 수: 4 (최근 30일)
Tony Yu
Tony Yu 2020년 6월 22일
댓글: Tony Yu 2020년 6월 22일
a1 = 0; alpha1 = 0; d1 = 0;
a2 = 475; alpha2 = pi/2; d2 = 150;
a3 = 600; alpha3 = 0; d3 = 0;
%DH parameter
t1_min = -pi/2; t1_max = pi/2;
t2_min = -pi/3; t2_max = pi/3;
t3_min = -pi/3; t3_max = pi/3;
% joint limits
% Monte Carlo method
% sampling size
N = 20000;
t1 = t1_min + (t1_max-t1_min)*rand(N,1);
t2 = t2_min + (t2_max-t2_min)*rand(N,1);
t3 = t3_min + (t3_max-t3_min)*rand(N,1);
function [ T ] = TranMat( 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
];
for i = 1:N
A1 = TransMat(a1,alpha1,d1,t1(i));
A2 = TransMat(a2,alpha2,d2,t2(i));
A3 = TransMat(a3,alpha3,d3,t3(i));
T = A1*A2*A3;
X=T(1,4);
Y=T(2,4);
Z=T(3,4);
plot3(X,Y,Z,'.')
hold on;
end
end

채택된 답변

Geoff Hayes
Geoff Hayes 2020년 6월 22일
Tony - your code is not calling the TranMat function which has the code to plot the data. How should it be called? What do the a, b, c, and d input parameters correspond to in the script code?
  댓글 수: 9
Tony Yu
Tony Yu 2020년 6월 22일
I tried your meathod but all 3 figures are showing view(3)...
Tony Yu
Tony Yu 2020년 6월 22일
It works now, seems like it does not need to call out plot3 again on figure 2 and 3, thanks !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by