Rank: 142 based on 409 downloads (last 30 days) and 1 file submitted
photo

Erik Johnson

E-mail
Company/University
Univ of Southern California

Personal Profile:

Associate Professor & Associate Chair, Astani Department of Civil & Env. Engineering, University of Southern California
B.S. (1988), M.S. (1993), Ph.D. (1997), Aeronautical & Astronautical Engineering, University of Illinois at Urbana-Champaign
http://www.usc.edu/dept/civil_eng/johnsone/

Professional Interests:

 

Watch this Author's files

 

Files Posted by Erik
Updated   File Tags Downloads
(last 30 days)
Comments Rating
20 May 2009 Screenshot arrow.m Draw a line with an arrowhead. Author: Erik Johnson arrow, potw, line, graphics, customization, arrowhead 409 54
  • 4.57627
4.6 | 61 ratings
Comments and Ratings on Erik's Files View all
Updated File Comment by Comments Rating
12 Jun 2010 arrow.m Draw a line with an arrowhead. Author: Erik Johnson zhang, Jiangmin

perfect!

19 May 2010 arrow.m Draw a line with an arrowhead. Author: Erik Johnson Notan

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 ;-)

10 May 2010 arrow.m Draw a line with an arrowhead. Author: Erik Johnson David

THANK YOU!!!!

08 May 2010 arrow.m Draw a line with an arrowhead. Author: Erik Johnson Christopher

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.

04 May 2010 arrow.m Draw a line with an arrowhead. Author: Erik Johnson Molecke, Ryan

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]);

Top Tags Applied by Erik
annotation, arrow, arrowhead, customization, graphics
Files Tagged by Erik
Updated   File Tags Downloads
(last 30 days)
Comments Rating
20 May 2009 Screenshot arrow.m Draw a line with an arrowhead. Author: Erik Johnson arrow, potw, line, graphics, customization, arrowhead 409 54
  • 4.57627
4.6 | 61 ratings

Contact us at files@mathworks.com