Filter löschen
Filter löschen

How to make matlab draw lines?

1 Ansicht (letzte 30 Tage)
Gemalyn Apostol
Gemalyn Apostol am 27 Okt. 2016
Beantwortet: Image Analyst am 27 Okt. 2016
How to make matlab draw lines between points (1,1) and (2,0); (3,1) and (2,4); and (2,2) and (3,4)?
I try this code but it didn't work.
x= [ 1 3 2; 2 2 3 ]
y= [ 1 1 2; 0 4 4 ]
plot (x,y)

Antworten (2)

KSSV
KSSV am 27 Okt. 2016
x = [ 1 3 2 2 2 3 ] ;
y= [ 1 1 2 0 4 4 ] ;
plot(x,y)
  1 Kommentar
Walter Roberson
Walter Roberson am 27 Okt. 2016
No, that would draw one line. The user wants to draw a series of short lines.

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 27 Okt. 2016
Try this:
x= [ 1 3 2; 2 2 3 ]
y= [ 1 1 2; 0 4 4 ]
for col = 1 : size(x, 2)
line(x(:, col), y(:, col), 'LineWidth', 3, 'Color', 'r');
end
grid on;
xlim([0, 4]);
ylim([0, 5]);

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by