The arrow.m
submission from FileExchange is what you need. It's hard to imagine that it's not built in, but at least this contribution fills the gap nicely. Here is an example using it like in that Q/A you linked to:
function randomWalk(seq)
n = length(seq);
ptStart = zeros(n, 3);
ptEnd = zeros(n, 3);
cols = jet(n);
for i=1:n
switch seq(i)
case 'A'
d = [1 0];
case 'T'
d = [-1 0];
case 'G'
d = [0 1];
case 'C'
d = [0 -1];
end
ptEnd(i,:) = ptStart(i,:) + [d 1];
ptStart(i+1,:) = ptEnd(i,:);
end
rng = [min([ptStart; ptEnd], [], 1); max([ptStart; ptEnd], [], 1)];
axis(rng(:))
for i=1:n
arrow(ptStart(i,:), ptEnd(i,:), 'BaseAngle', 90,...
'TipAngle', 15,...
'Length', 30,...
'CrossDir', [1 1 0],...
'EdgeColor', cols(i,:),...
'FaceColor', cols(i,:));
end
axis equal
view([45 15])
>> randomWalk('ATGCGTCGTAACGT')
