gpt4 book ai didi

matlab - matlab曲面图的自定义颜色

转载 作者:太空宇宙 更新时间:2023-11-03 19:52:29 24 4
gpt4 key购买 nike

我已经将一些地形数据加载到 matlab 中,并创建了这些数据的 surf、surfl 和等高线图,并使用 colormap 为它们着色。地形数据范围为0~2500 m。

我想绘制一张 map ,将 200 米以下的任何地形着色为蓝色,500 米以上为红色,200 到 500 米之间为绿色。是否有可能做到这一点?谁能给我任何有关执行此操作所需命令的提示?

非常感谢

最佳答案

您可以使用colormapsurf 的第四个输入。

下图

enter image description here

产生于

[X,Y,Z] = peaks(1000);

%colormap
cmap = [0.6 0.2 0.4;
0.5 0.5 0.5;
0.1 0.9 0.9];

Zcolor = zeros(size(Z));
threshold = 2;
Zcolor(Z <= -threshold) = 1; % first row of cmap
Zcolor(Z > -threshold & Z < threshold) = 2; % second row of cmap
Zcolor(Z >= threshold) = 3; % third row of cmap

figure('Color','w');
surf(X, Y, Z, Zcolor, 'EdgeColor', 'None');
colormap(cmap);
light('Position', [0 -2 1])

关于matlab - matlab曲面图的自定义颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20214734/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com