Matlab ploting an arrow between two points (not just a line)

Viewed 2825

Following up on this lovely answer https://stackoverflow.com/a/45442483/2798895 how to draw a line between two sets of points I need to have an arrow (--->) between the corresponding points. Is there a way of doint it?

I found some examples of using quiver but they don't connect from (x,y) to (u,v). They are adding only a short arrow to (x,y) that is pointing in the direction of (u,v) but not touching it.

My line plot (from the above mentioned answer):

set1 = [1,2; 3,4; 5,6];
set2 = [10,20; 30,40; 50,60];
figure; 
plot(set1(:,1),set1(:,2),'b+',set2(:,1),set2(:,2),'g+')
hold on
x = [set1(:,1) set2(:,1)].';
y = [set1(:,2) set2(:,2)].';
plot(x,y,'r')
hold off
drawnow 

My quiver plot:

set1 = [1,2; 3,4; 5,6];
set2 = [10,20; 30,40; 50,60];
figure; 
plot(set1(:,1),set1(:,2),'b+',set2(:,1),set2(:,2),'g+')
hold on
quiver(set1(:,1),set1(:,2),set2(:,1),set2(:,2));
hold off
drawnow 

How would that be possible to connect the points with an arrow e.g. like quiver but with longer arrows?

0 Answers
Related