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:

답변 (1개)

Mike Garrity
Mike Garrity 2015년 4월 15일
편집: Mike Garrity 2015년 4월 15일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

태그

질문:

2015년 4월 15일

편집:

2015년 4월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by