MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   在填充轮廓中绘制最高点 (https://www.labfans.com/bbs/showthread.php?t=23748)

poster 2019-12-10 20:48

在填充轮廓中绘制最高点
 
嗨,有人可以在这里用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时,会出错。



[B]回答:[/B]

要绘制红色的“ X”,必须先调用hold on以确保第二个绘制命令不会擦除轮廓。然后,使用plot(xMax,yMax,'xr')在x / y坐标处绘制红色的'x',其中z为其最大值。

要找到xMax和yMax ,必须使用max的第二个输出参数。 [URL="http://www.mathworks.com/access/helpdesk/help/techdoc/ref/max.html"]MAX[/URL]作为第一个输出返回最大值(例如Z ),而作为第二个输出,返回最大值的元素编号。使用该数字(索引)查找X和Y中与最大Z值相对应的元素,即xMax和yMax 。



[url=https://stackoverflow.com/questions/3381382]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 01:04

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.