Works great, but the Arrowtips do not look perfect by default as they are the connection of two line ends and therefore not round in pdf printouts.
You can workaround this issue by drawing the arrow in the opposite direction and use parameter: 'End','start'.
But nonetheless it would be nice if they would be perfect by default ;-)
This code, at least on R2009a, looks very strange.
close all; clc;
figure(1)
arrow([0;0;0],[1;0;0])
arrow([0;0;0],[0;1;0])
arrow([0;0;0],[0;0;1])
axis([-1 1 -1 1 -1 1])
I'm really having trouble with 3-D plots and arrows pointing along the 3rd axis.
I found this implementation to be slow and lacking. Admittedly I was drawing thousands of arrows at extremely short lengths. Here is an inline function I wrote in about 5 minutes to draw simple arrows.
function out = draw_arrow(startpoint,endpoint,headsize)
%by Ryan Molecke
v1 = headsize*(startpoint-endpoint)/2.5;
theta = 22.5*pi/180;
theta1 = -1*22.5*pi/180;
rotMatrix = [cos(theta) -sin(theta) ; sin(theta) cos(theta)];
rotMatrix1 = [cos(theta1) -sin(theta1) ; sin(theta1) cos(theta1)];
v2 = v1*rotMatrix;
v3 = v1*rotMatrix1;
x1 = endpoint;
x2 = x1 + v2;
x3 = x1 + v3;
hold on;
% below line fills the arrowhead (black)
fill([x1(1) x2(1) x3(1)],[x1(2) x2(2) x3(2)],[0 0 0]);
% below line draws line (black)
plot([startpoint(1) endpoint(1)],[startpoint(2) endpoint(2)],'linewidth',2,'color',[0 0 0]);
Comment only