How to connect points in a plot with a line
Show older comments
Hi, I'm trying to join some points with a line in a point plot I have created in order to draw the figure shown (ignore the dimensions).

Here's my code so far:
%Data
thta = 60;
L1 = 600;
%Coordinates 1
P1 = [700;-50;0];
P2 = [600;-50;0];
P3 = [600;0;0];
P4 = [600;50;0];
P5 = [700;50;0];
%Coordinates 2
P6 = [500;-70;0];
P7 = [500;0;0];
P8 = [500;70;0];
P9 = [0;-70;0];
P10 = [0;70;0];
%Equation
rotz = [cosd(thta) -sind(thta) 0;sind(thta) cosd(60) 0;0 0 1];
%Final positions 1
pf1 = rotz*P1;
pf2 = rotz*P2;
pf3 = rotz*P3;
pf4 = rotz*P4;
pf5 = rotz*P5;
%Final positions 2
pf6 = rotz*P6;
pf7 = rotz*P7;
pf8 = rotz*P8;
pf9 = rotz*P9;
pf10 = rotz*P10;
% Point Plot
x1 = pf1(1,1);
y1 = pf1(2,1);
x2 = pf2(1,1);
y2 = pf2(2,1);
x3 = pf3(1,1);
y3 = pf3(2,1);
x4 = pf4(1,1);
y4 = pf4(2,1);
x5 = pf5(1,1);
y5 = pf5(2,1);
x6 = pf6(1,1);
y6 = pf6(2,1);
x7 = pf7(1,1);
y7 = pf7(2,1);
x8 = pf8(1,1);
y8 = pf8(2,1);
x9 = pf9(1,1);
y9 = pf9(2,1);
x10 = pf10(1,1);
y10 = pf10(2,1);
figure
g1 = plot(x1,y1,'s')
xlim([-100 800])
ylim([-100 800])
title('Posiciones finales')
hold on
g2 = plot(x2,y2,'s')
plot(x3,y3,'s')
plot(x4,y4,'s')
plot(x5,y5,'s')
plot(x6,y6,'s')
plot(x7,y7,'s')
plot(x8,y8,'s')
plot(x9,y9,'s')
plot(x10,y10,'s')
hold off
Any ideas?
The figure obtained in Matlab is the following:

Accepted Answer
More Answers (0)
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!