


arrowPlot: Plot an arrow on an existing plot
Usage: arrowH = arrowPlot(beingPoint, endPoint)
arrowH: Returned handle to the plotted arrow
beginPoint: Start point of the arrow (must be a complex number)
endPoint: End point of the arrow (must be a complex number)
color: Color of the arrow (optional, should be 3-element vector)
For instance:
arrowPlot(1+j, 2+3j, [1 0 0]); axis image


0001 function arrowH = arrowPlot(beginPoint, endPoint, color) 0002 % arrowPlot: Plot an arrow on an existing plot 0003 % Usage: arrowH = arrowPlot(beingPoint, endPoint) 0004 % arrowH: Returned handle to the plotted arrow 0005 % beginPoint: Start point of the arrow (must be a complex number) 0006 % endPoint: End point of the arrow (must be a complex number) 0007 % color: Color of the arrow (optional, should be 3-element vector) 0008 % 0009 % For instance: 0010 % 0011 % arrowPlot(1+j, 2+3j, [1 0 0]); axis image 0012 0013 % Roger Jang, 20001130 0014 0015 if nargin==0, selfdemo; return; end 0016 0017 arrowX = [-1 0 -0.1 -0.12 -0.02 -0.12 -0.1 0]; 0018 arrowY = [0 0 0.1 0.1 0 -0.1 -0.1 0]; 0019 basicArrow = 1+arrowX + j*arrowY; 0020 newArrow = (endPoint-beginPoint)*basicArrow + beginPoint; 0021 0022 arrowH = line(real(newArrow), imag(newArrow), 'color', 'k', 'clip', 'off'); 0023 if nargin==3, 0024 set(arrowH, 'color', color); 0025 end 0026 0027 function selfdemo 0028 for i=1:10, 0029 beginPoint = rand+j*rand; 0030 endPoint = rand+j*rand; 0031 color = [rand, rand, rand]; 0032 arrowPlot(beginPoint, endPoint, color); 0033 box on; 0034 axis image; 0035 end