Albo
Albo

Reputation: 25

Connecting points in matlab

I am working in matlab and I have 2 arrays with the following points

qazX = 5   5
       6   47
       7   38
       8   29
       9   10
       10  31

qazY = 15    16
       16    57
       17    28
       18    49
       19    30
       20    25

I want to connect the 2 arrays. For example I want the line between (5,5) and (15,16), and then a separate line from (6,47) to (16,57) and so on.

I have tried the following code but none seem to work. Any help is much appreciated.

    plot(qazX,qazY)

    plot(qazX(:,1),qazX(:,2),qazY(:,1),qazY(:,2))

    plot([qazX(:,1),qazY(:,1)],[qazX(:,2),qazY(:,2)])

Upvotes: 2

Views: 78

Answers (1)

Dan
Dan

Reputation: 45741

You were very close:

plot([qazX(:,1),qazY(:,1)]',[qazX(:,2),qazY(:,2)]')

enter image description here

Upvotes: 4

Related Questions