0

我想用这个创建一个三维表面:

>> a=X

a =

Columns 1 through 8

           0          50         100         150         200         250         300         350

Columns 9 through 16

         400         450         500         550         600         650         700         750

Columns 17 through 21

         800         850         900         950        1000

>> b=Y

b =

     0
    50
   100
   150
   200
   250
   300
   350
   400

>> c=Z

c =
Columns 1 through 8

           0           0           0           0           0           0           0           0
          16          32          67          98         127         164         194         234
         120         171         388         773        1086        1216        1770        2206
         189         270         494        1978        2755        3134        5060       10469
         133         166         183         348         647         937        1446        2304
         192         162         154         113         161         189         266         482
           0           0           0           0           0           0           0           0
           0           0           0           0           0           0           0           0
           0           0           0           0           0           0           0           0

Columns 9 through 16

           0           0           0           0           0           0           0           0
         366         604         529         504         346         226         228         179
        4027       11186       10276        5349        2560        1322         996         799
       27413       76387       37949       15591        5804        2654        1803        1069
        9844       24152       14772        4613        1777         849         459         290
        1288        2623        1538         582         280         148          90          56
           0           0           0           0           0           0           0           0
           0           0           0           0           0           0           0           0
           0           0           0           0           0           0           0           0

Columns 17 through 21

           0           0           0           0           0
         108          94          79           0           0
         646         476         612           0           0
         884         858         722           0           0
         266         215         139           0           0
          48          48          31           0           0
           0           0           0           0           0
           0           0           0           0           0
           0           0           0           0           0



>> surf(X,Y,Z)

同时我想定义 Z 值 < = 1803 将在曲面图上以红色显示,1803 < Z < 2755 黄色和 Z > = 2755 绿色。颜色条的限制可以是 Z 的最小值和最大值(从 0 到 76387)。如何设置颜色条的范围以获得此结果?

4

1 回答 1

2

这将按照您的要求进行:

%# add red (row 1), yellow (row 2), green (row 2)
map = [1 0 0; 0 1 1; 0 1 0];  

%# set the new map as the current map
colormap(map); 

colors = zeros(size(c));          %# create colors array          
colors(c <= 1803) = 1;            %# red (1)
colors(c > 1803 & c < 2755) = 2;  %# yellow (2)
colors(c >= 2755) = 3;            %# green (3)

%# and pass it into surf     
surf(a,b,c, colors) 
于 2012-09-28T10:02:53.167 回答