 function plotline2(x)

% function plotline2(x)
% 
% Graphically represents the span of one vector in R^2.


 x1 = x/norm(x);   % normalize the vector to have length 1

% plot the line
 plot([-x1(1) x1(1)],[-x1(2) x1(2)],'k-','linewidth',2) 
 hold on

 x2 = [x1(2); -x1(1)];       % compute a vector orthogonal to x1

% the following lines plot some crude arrowheads
 h = .035;
 arrowhead = [x1+h*x2 (1+2*h)*x1 x1-h*x2];
 fill(arrowhead(1,:),arrowhead(2,:),'k','edgecolor','k')
 fill(-arrowhead(1,:),-arrowhead(2,:),'k','edgecolor','k')

 axis equal, axis(2.1*[-1 1 -1 1])
