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时,会出错。
回答:
要绘制红色的“ X”,必须先调用hold on以确保第二个绘制命令不会擦除轮廓。然后,使用plot(xMax,yMax,'xr')在x / y坐标处绘制红色的'x',其中z为其最大值。
要找到xMax和yMax ,必须使用max的第二个输出参数。 MAX (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/max.html)作为第一个输出返回最大值(例如Z ),而作为第二个输出,返回最大值的元素编号。使用该数字(索引)查找X和Y中与最大Z值相对应的元素,即xMax和yMax 。
更多&回答... (https://stackoverflow.com/questions/3381382)
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”,必须先调用hold on以确保第二个绘制命令不会擦除轮廓。然后,使用plot(xMax,yMax,'xr')在x / y坐标处绘制红色的'x',其中z为其最大值。
要找到xMax和yMax ,必须使用max的第二个输出参数。 MAX (http://www.mathworks.com/access/helpdesk/help/techdoc/ref/max.html)作为第一个输出返回最大值(例如Z ),而作为第二个输出,返回最大值的元素编号。使用该数字(索引)查找X和Y中与最大Z值相对应的元素,即xMax和yMax 。
更多&回答... (https://stackoverflow.com/questions/3381382)