3D scale bar for mesh/surf?

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

Asked:

on 15 Apr 2015

Edited:

on 15 Apr 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!