How to add a 'marker' and a 'textbox' for a given x,y,z in a surface?

조회 수: 3 (최근 30일)
A
A 2015년 5월 31일
댓글: Walter Roberson 2015년 6월 2일
Hi guys,
A relatively simple question. I want to graph the below surface. But with it, I want to highlight just ONE point based on a given x,y (in this case f1, f2) and have a related textbox appear which gives me the coordinates. For example, like this:
*X-Value: 4 Y-value:5 Z-value: 2
I tried data cursor, but it requires that you click on it and it doesn't become PART OF the surface.
Thank you. Here is the test surface:
x = [0:20];
y = [0:20];
f1 = 1;
f2 = 2;
constant = 3;
% Calculate data
TestFormula = @(x,y)(x + y.*constant);
[X,Y] = meshgrid(x,y);
Z1 = TestFormula(X,Y);
Z2 = TestFormula(f1,f2);
% Create frequency plot in proper axes
s1 = surf(X,Y,Z1);
xlabel('X', 'fontweight', 'bold')
ylabel('Y', 'fontweight', 'bold')
view (135,15);
yh = get(gca,'YLabel'); % Handle of the y label
set(yh, 'Units', 'Normalized')
pos = get(yh, 'Position');
set(yh, 'Position',pos.*[0.85,0.6,1],'Rotation',-10.9)
xh = get(gca,'XLabel'); % Handle of the x label
set(xh, 'Units', 'Normalized')
pos = get(xh, 'Position');
set(xh, 'Position',pos.*[1,1,1],'Rotation',11.1)
zlabel('Z', 'fontweight', 'bold')
zh = get(gca,'ZLabel'); % Handle of the z label
set(zh, 'Units', 'Normalized')
pos = get(zh, 'Position');
set(zh, 'Position',pos.*[1.5,1,0],'Rotation',90)
axis tight
camlight
lighting phong
shading interp
set(s1,'FaceColor',[0 0.63 0.91], 'edgecolor',[0 0 0.4],'meshstyle','both','linewidth',.15);
grid on

답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by