can't plot
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
syms p1
th1 = 0
ap1 = 0
a1 = 0
b1 = 0.5
c1 = 0
R1z = [ cos(p1), -sin(p1),0, 0;
sin(p1), cos(p1), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
M1y = [1, 0, 0, a1;
0, 1, 0, b1;
0, 0, 1, c1;
0, 0, 0, 1];
TM1 = R1z*M1y
syms ap2
th2 = 0
p2 = 0
a2 = 0
b2 = 0
c2 = 0.3
R2y = [ cos(ap2),0, -sin(ap2), 0;
0, 1, 0, 0;
sin(ap2), 0, cos(ap2), 0;
0, 0, 0, 1];
M2z = [1, 0, 0, a2;
0, 1, 0, b2;
0, 0, 1, c2;
0, 0, 0, 1];
TM2 = R2y*M2z
syms ap3
th3 = 0
ap3 = 0
a3 = 0
b3 = 0
c3 = 0.2
R3y = [ cos(ap3),0, -sin(ap3), 0;
0, 1, 0, 0;
sin(ap3), 0, cos(ap3), 0;
0, 0, 0, 1];
M3z = [1, 0, 0, a3;
0, 1, 0, b3;
0, 0, 1, c3;
0, 0, 0, 1];
TM3 = R3y* M3z
syms ap4
th4 = 0
p4 = 0
a4 = 0
b4 = 0
c4 = 0.2
R4y = [ cos(ap4),0, -sin(ap4), 0;
0, 1, 0, 0;
sin(ap4), 0, cos(ap4), 0;
0, 0, 0, 1];
M4z = [1, 0, 0, a3;
0, 1, 0, b3;
0, 0, 1, c3;
0, 0, 0, 1];
TM4 = R4y* M4z
TM1
T12=mtimes(TM1,TM2)
T123=mtimes(TM1,mtimes(TM2,TM3))
T1234=mtimes(TM1,mtimes(TM2,mtimes(TM3,TM4)))
%%ex.3.2
L1=0.5
L2=0.3
L3=0.2
for i=1:1:20
for j= 1:1:20
ap2=pi/10*i
p1=pi/10*j
ap3=pi/10*j
rrrrrx= -sin(p1)/2 %링크1의 x좌표
rrrrry=cos(p1)/2 %링크1의 y좌표
rrrrrz= 0 %링크1의 z좌표
rrrrx= -sin(p1)/2 - (3*cos(p1)*sin(ap2))/10 %링크2의 x좌표
rrrry= cos(p1)/2 - (3*sin(ap2)*sin(p1))/10 %링크2의 y좌표
rrrrz= (3*cos(ap2))/10 %링크2의 z좌표
rrrx= - sin(p1)/2 - (cos(p1)*sin(ap2))/2 %링크3의 x좌표
rrry= cos(p1)/2 - (sin(ap2)*sin(p1))/2 %링크3의 y좌표
rrrz= cos(ap2)/2 %링크3의 z좌표
rrx= - sin(p1)/2 - cos(p1)*((3*sin(ap2))/10 + sin(ap2)*(cos(ap4)/5 + 1/5) + (cos(ap2)*sin(ap4))/5) %링크4의 x좌표
rry= cos(p1)/2 - sin(p1)*((3*sin(ap2))/10 + sin(ap2)*(cos(ap4)/5 + 1/5) + (cos(ap2)*sin(ap4))/5) %링크4의 y좌표
rrz= (3*cos(ap2))/10 - (sin(ap2)*sin(ap4))/5 + cos(ap2)*(cos(ap4)/5 + 1/5) %링크4의 z좌표
rx=[rrrrrx,rrrrx,rrrx,rrx];
ry=[rrrrry,rrrry,rrry,rry]
rz=[rrrrrz,rrrrz,rrrz,rrz]
plot3(rx,ry,rz,'-');
axis([-2 2 -2 2 -2 2])
figure(3)
end
end
I'm kind of a new for matlab.. please help! i can't plot this simulation
3 commentaires
Image Analyst
le 27 Mai 2020
If yes, and you cannot convert them from symbolic to arrays with linspace(), then I can't run it because I don't have the Symbolic toolbox. If you make them arrays, I might have a chance.
Réponses (2)
VBBV
le 8 Nov 2023
syms p1 ap2 ap3 ap4
th1 = 0;
ap1 = 0;
a1 = 0;
b1 = 0.5;
c1 = 0;
R1z = [ cos(p1), -sin(p1),0, 0;
sin(p1), cos(p1), 0, 0;
0, 0, 1, 0;
0, 0, 0, 1];
M1y = [1, 0, 0, a1;
0, 1, 0, b1;
0, 0, 1, c1;
0, 0, 0, 1];
TM1 = R1z*M1y;
th2 = 0;
p2 = 0;
a2 = 0;
b2 = 0;
c2 = 0.3;
R2y = [ cos(ap2),0, -sin(ap2), 0;
0, 1, 0, 0;
sin(ap2), 0, cos(ap2), 0;
0, 0, 0, 1];
M2z = [1, 0, 0, a2;
0, 1, 0, b2;
0, 0, 1, c2;
0, 0, 0, 1];
TM2 = R2y*M2z;
th3 = 0;
ap3 = 0;
a3 = 0;
b3 = 0;
c3 = 0.2;
R3y = [ cos(ap3),0, -sin(ap3), 0;
0, 1, 0, 0;
sin(ap3), 0, cos(ap3), 0;
0, 0, 0, 1];
M3z = [1, 0, 0, a3;
0, 1, 0, b3;
0, 0, 1, c3;
0, 0, 0, 1];
TM3 = R3y* M3z;
th4 = 0;
ap4 = 0;
p4 = 0;
a4 = 0;
b4 = 0;
c4 = 0.2;
R4y = [ cos(ap4),0, -sin(ap4), 0;
0, 1, 0, 0;
sin(ap4), 0, cos(ap4), 0;
0, 0, 0, 1];
M4z = [1, 0, 0, a3;
0, 1, 0, b3;
0, 0, 1, c3;
0, 0, 0, 1];
TM4 = R4y* M4z;
TM1;
T12=mtimes(TM1,TM2);
T123=mtimes(TM1,mtimes(TM2,TM3));
T1234=mtimes(TM1,mtimes(TM2,mtimes(TM3,TM4)));
%%ex.3.2
L1=0.5;
L2=0.3;
L3=0.2;
hold on
for i=1:1:20
for j= 1:1:20
ap2=pi/10*i;
p1=pi/10*j;
ap3=pi/10*j;
ap4 = pi/10*j;
rrrrrx= -sin(p1)/2; %링크1의 x좌표
rrrrry=cos(p1)/2; %링크1의 y좌표
rrrrrz= 0 ; %링크1의 z좌표
rrrrx= -sin(p1)/2 - (3*cos(p1)*sin(ap2))/10; %링크2의 x좌표
rrrry= cos(p1)/2 - (3*sin(ap2)*sin(p1))/10; %링크2의 y좌표
rrrrz= (3*cos(ap2))/10; %링크2의 z좌표
rrrx= - sin(p1)/2 - (cos(p1)*sin(ap2))/2; %링크3의 x좌표
rrry= cos(p1)/2 - (sin(ap2)*sin(p1))/2; %링크3의 y좌표
rrrz= cos(ap2)/2; %링크3의 z좌표
rrx= - sin(p1)/2 - cos(p1)*((3*sin(ap2))/10 + sin(ap2)*(cos(ap4)/5 + 1/5) + (cos(ap2)*sin(ap4))/5); %링크4의 x좌표
rry= cos(p1)/2 - sin(p1)*((3*sin(ap2))/10 + sin(ap2)*(cos(ap4)/5 + 1/5) + (cos(ap2)*sin(ap4))/5); %링크4의 y좌표
rrz= (3*cos(ap2))/10 - (sin(ap2)*sin(ap4))/5 + cos(ap2)*(cos(ap4)/5 + 1/5); %링크4의 z좌표
rx=[rrrrrx,rrrrx,rrrx,rrx];
ry=[rrrrry,rrrry,rrry,rry];
rz=[rrrrrz,rrrrz,rrrz,rrz];
plot3(double(rx),double(ry),double(rz),'b.');
axis([-2 2 -2 2 -2 2])
end
end
% view(3)
0 commentaires
Vaibhav Tomar
le 31 Mai 2020
Hey
Conversion to arrays might make it easier to analyse the specific issue with the execution. It might be better if you could assign some range for p1,ap2,etc.
0 commentaires
Voir également
Catégories
En savoir plus sur Special Values dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!