Plotting multiple separate lines

8 visualizaciones (últimos 30 días)
Tchilabalo
Tchilabalo el 24 de Mayo de 2019
Comentada: Star Strider el 24 de Mayo de 2019
x1=[0 2 3]
y1=[11 19 12]
x2=[24 25 22]
y2=[36 38 39]
for i=1:length(x1)
A = [x1 y1]; B = [x2 y2];
plot(A,B)
end
axis([0 50 0 50])
I have the two endpoints ((x1,y1); (x2,y2)) of three lines as shown above. I want to plot these a separate lines. But when i use "plot" function, the lines are connected. I will appreciate your help.

Respuesta aceptada

Star Strider
Star Strider el 24 de Mayo de 2019
Plot them as column vectors, not row vectors.
Try this:
A = [x1(:) y1(:)]; B = [x2(:) y2(:)];
I am not certain what result you want, so you may need to experiment.
  2 comentarios
Tchilabalo
Tchilabalo el 24 de Mayo de 2019
x1=[1 2 3]
y1=[4 5 8]
x2=[24 25 22]
y2=[43 46 49]
for i=1:length(x1)
A = [x1(:) x2(:)]; B = [y1(:) y2(:)];
plot(A.',B.','LineWidth', 0.75)
end
axis([0 50 0 50])
Thanks for your reply. I made some minor changes to get what i wanted.
Star Strider
Star Strider el 24 de Mayo de 2019
As always, my pleasure.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by