3D scale bar for mesh/surf?
Show older comments
I can't seem to find s scale-bar-making function in MATLAB. I need it for a mesh that I made with dimensions in millimeters. Can anyone help me with this please? I want it to be something like this:

Answers (1)
Mike Garrity
on 15 Apr 2015
Edited: Mike Garrity
on 15 Apr 2015
You could start with something like this:
function scalebar(xc,yc,zc, w, label)
x = [xc, xc-w, nan, xc, xc , nan, xc, xc ];
y = [yc, yc , nan, yc, yc-w, nan, yc, yc ];
z = [zc, zc , nan, zc, zc , nan, zc, zc+w];
hl = line(x,y,z);
hl.LineWidth = 2;
ht = text(xc,yc,zc,[num2str(w), ' ', units]);
ht.FontSize = 18;
ht.Color = hl.Color;
ht.VerticalAlignment = 'bottom';
The nans are to insert breaks in between the individual line segments.
I can use it like this:
[x,y,z]=peaks;
surf(x,y,z)
scalebar(-.1,1.4,8.5, 2, 'Feet')
to get this:

%
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!