This code allows you to create simple, yet powerful three dimensional arrow. As it is derived from the surf command, it may be memory intensive, but well worth the cost for crisp visualization of data using phong shading and MATLAB's lighting options.
%% Creates a single arrow starting at the origin with magnitude=1 along the z-axis, in red, with an arrowhead 18% of the length and the stem 82% of the length.
This has a 'published' file, so use:
to view many of the details or simply view directly the html file attached.
Shawn Arseneau (2021). 3D Arrow with many color/parameter options (https://www.mathworks.com/matlabcentral/fileexchange/12274-3d-arrow-with-many-color-parameter-options), MATLAB Central File Exchange. Retrieved .
Nice work I made some improvements:
1. The arrow head was not pointy but cut off at top
To fix this just change Cone generation to
[coneX, coneY, coneZ] = cylinder(linspace(cylinderRadius*2,0,incr));
2. The base of the cylinder/stem and the arrowhead/cone is not painted. To do just add
hHeadBase1 = fill3(headX(1,:),headY(1,:),headZ(1,:),colorCode,'EdgeColor','none','HandleVisibility','off');
hStemBase1 = fill3(stemX(1,:),stemY(1,:),stemZ(1,:),colorCode,'EdgeColor','none','HandleVisibility','off');
There is a bug on line 71. It should be:
Otherwise, the base radius of the cone does not vary with the 'coneRadius' parameter above.
Also, it should be sufficient to use
incr = 1
on line 69
Thanks for the useful function
Works fine. Although I would like to have more info/help.
Nicely improved. This now deserves a 5 rating.
Nice arrows. My only comment is that I'd prefer to see only two inputs, as vectors instead of 6 inputs. Thus you would call it as
This would seem generally easier to use programmatically, since most of the time this information is already in one vector anyway. For multiple arrows, supply an array.
Its a minor point, and purely style, so I'd otherwise leave my rating as a 5. I chose to downrate this to a 4 because the author forgot to include the meanings of the parameters in the help for this function. Yes, the demo file is very nice, and I like to see examples. But next year or next month when I want to use this code, I'll need to get help for it in matlab. This help is useless. Are Qx,Qy,Qz the end points of the arrow or the delta in each dimension? What are the explicit meanings for colorCode and stemRatio?
I actually wanted to rate this lower because of the poor included help, but I liked it enough to leave it as a 4. I'll hope the author chooses to upgrade the help. I'd also love to see a better H1 line. As it is, the function lookfor will never see this function, so next year when you want to use this code, you may not even find it anyway.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!