Matlab 绘制填充轮廓中的最高点

Matlab 绘制填充轮廓中的最高点,matlab,plot,max,contour,Matlab,Plot,Max,Contour,大家好,这里有人能帮我使用Matlab命令吗。我必须确定填充轮廓中的最高点,我用文件中的矩阵数据绘制了这个轮廓。然后我必须用红色的x标记最高点 load('0101862_mod.dtm') % loading the dtm file X = X0101862_mod(1:81,:) % we name X0101862, it is the location where the data X, Y and Z is stored Y = X0101862_mod(82:162,:) Z

大家好,这里有人能帮我使用Matlab命令吗。我必须确定填充轮廓中的最高点,我用文件中的矩阵数据绘制了这个轮廓。然后我必须用红色的
x
标记最高点

load('0101862_mod.dtm')   % loading the dtm file
X = X0101862_mod(1:81,:)  % we name X0101862, it is the location where the data X, Y and Z is stored
Y = X0101862_mod(82:162,:)
Z = X0101862_mod (163:243,:)

figure (1)
subplot(2,2,3)
[C,h] = contourf(X,Y,Z,10);
xlabel('x'); ylabel('y'); zlabel('z'); title('X0101862_mod');
view(-73,34); axis equal; colormap summer; colorbar;

我知道这涉及到
max
命令。当我使用
max

绘制红色的“X”时,不断出现错误,您必须先调用
按住
,以确保第二个绘制命令不会删除轮廓。然后,使用
plot(xMax,yMax,'xr')
在z最大的x/y坐标处绘制红色的“x”


要查找
xMax
yMax
,必须使用
max
的第二个输出参数。作为第一个输出,返回最大值(例如,
Z
),作为第二个输出,返回最大元素的数目。使用该数字(索引)查找
X
Y
中对应于最大
Z
-值的元素,即
xMax
yMax

是否正确?xMax=最大值(X);yMax=最大值(Y);绘图(xMax,yMax,'xr');否。xMax是对应于最大Z的X。
[zMax,maxIdx]=max(Z)
返回数据向量中
maxIdx
Z
最高的位置。例如,如果Z中的第五个元素最高,
maxIdx
将为5。相应地,xMax将是
X
的第五个元素,yMax将是
Y
的第五个元素。