• Matlab基本函数-colormap函数


    1、colormap函数:获取当前色图

    2、用法说明:colormap(map)函数设置或获取当前图像的色图。

                           参量map为一个m×3的、元素在[0,1]之间的实数矩阵,每一行是定义一种颜色的一个RGB向量。

                           颜色图的第k行定义第k种颜色,其中map(k,:)=[r(k) g(k) b(k)]定义红绿蓝的亮度。

    3、实例

    (1)源码

    >> t = 0:pi/6:pi*2
    
    t =
    
      Columns 1 through 10
    
             0    0.5236    1.0472    1.5708    2.0944    2.6180    3.1416    3.6652    4.1888    4.7124
    
      Columns 11 through 13
    
        5.2360    5.7596    6.2832
    
    >> [x,y,z] = cylinder(0.5*sin(t))
    
    x =
    
      Columns 1 through 10
    
             0         0         0         0         0         0         0         0         0         0
        0.2500    0.2378    0.2023    0.1469    0.0773    0.0000   -0.0773   -0.1469   -0.2023   -0.2378
        0.4330    0.4118    0.3503    0.2545    0.1338    0.0000   -0.1338   -0.2545   -0.3503   -0.4118
        0.5000    0.4755    0.4045    0.2939    0.1545    0.0000   -0.1545   -0.2939   -0.4045   -0.4755
        0.4330    0.4118    0.3503    0.2545    0.1338    0.0000   -0.1338   -0.2545   -0.3503   -0.4118
        0.2500    0.2378    0.2023    0.1469    0.0773    0.0000   -0.0773   -0.1469   -0.2023   -0.2378
        0.0000    0.0000    0.0000    0.0000    0.0000    0.0000   -0.0000   -0.0000   -0.0000   -0.0000
       -0.2500   -0.2378   -0.2023   -0.1469   -0.0773   -0.0000    0.0773    0.1469    0.2023    0.2378
       -0.4330   -0.4118   -0.3503   -0.2545   -0.1338   -0.0000    0.1338    0.2545    0.3503    0.4118
       -0.5000   -0.4755   -0.4045   -0.2939   -0.1545   -0.0000    0.1545    0.2939    0.4045    0.4755
       -0.4330   -0.4118   -0.3503   -0.2545   -0.1338   -0.0000    0.1338    0.2545    0.3503    0.4118
       -0.2500   -0.2378   -0.2023   -0.1469   -0.0773   -0.0000    0.0773    0.1469    0.2023    0.2378
       -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000    0.0000    0.0000    0.0000    0.0000
    
      Columns 11 through 20
    
             0         0         0         0         0         0         0         0         0         0
       -0.2500   -0.2378   -0.2023   -0.1469   -0.0773   -0.0000    0.0773    0.1469    0.2023    0.2378
       -0.4330   -0.4118   -0.3503   -0.2545   -0.1338   -0.0000    0.1338    0.2545    0.3503    0.4118
       -0.5000   -0.4755   -0.4045   -0.2939   -0.1545   -0.0000    0.1545    0.2939    0.4045    0.4755
       -0.4330   -0.4118   -0.3503   -0.2545   -0.1338   -0.0000    0.1338    0.2545    0.3503    0.4118
       -0.2500   -0.2378   -0.2023   -0.1469   -0.0773   -0.0000    0.0773    0.1469    0.2023    0.2378
       -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000    0.0000    0.0000    0.0000    0.0000
        0.2500    0.2378    0.2023    0.1469    0.0773    0.0000   -0.0773   -0.1469   -0.2023   -0.2378
        0.4330    0.4118    0.3503    0.2545    0.1338    0.0000   -0.1338   -0.2545   -0.3503   -0.4118
        0.5000    0.4755    0.4045    0.2939    0.1545    0.0000   -0.1545   -0.2939   -0.4045   -0.4755
        0.4330    0.4118    0.3503    0.2545    0.1338    0.0000   -0.1338   -0.2545   -0.3503   -0.4118
        0.2500    0.2378    0.2023    0.1469    0.0773    0.0000   -0.0773   -0.1469   -0.2023   -0.2378
        0.0000    0.0000    0.0000    0.0000    0.0000    0.0000   -0.0000   -0.0000   -0.0000   -0.0000
    
      Column 21
    
             0
        0.2500
        0.4330
        0.5000
        0.4330
        0.2500
        0.0000
       -0.2500
       -0.4330
       -0.5000
       -0.4330
       -0.2500
       -0.0000
    
    
    y =
    
      Columns 1 through 10
    
             0         0         0         0         0         0         0         0         0         0
             0    0.0773    0.1469    0.2023    0.2378    0.2500    0.2378    0.2023    0.1469    0.0773
             0    0.1338    0.2545    0.3503    0.4118    0.4330    0.4118    0.3503    0.2545    0.1338
             0    0.1545    0.2939    0.4045    0.4755    0.5000    0.4755    0.4045    0.2939    0.1545
             0    0.1338    0.2545    0.3503    0.4118    0.4330    0.4118    0.3503    0.2545    0.1338
             0    0.0773    0.1469    0.2023    0.2378    0.2500    0.2378    0.2023    0.1469    0.0773
             0    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000
             0   -0.0773   -0.1469   -0.2023   -0.2378   -0.2500   -0.2378   -0.2023   -0.1469   -0.0773
             0   -0.1338   -0.2545   -0.3503   -0.4118   -0.4330   -0.4118   -0.3503   -0.2545   -0.1338
             0   -0.1545   -0.2939   -0.4045   -0.4755   -0.5000   -0.4755   -0.4045   -0.2939   -0.1545
             0   -0.1338   -0.2545   -0.3503   -0.4118   -0.4330   -0.4118   -0.3503   -0.2545   -0.1338
             0   -0.0773   -0.1469   -0.2023   -0.2378   -0.2500   -0.2378   -0.2023   -0.1469   -0.0773
             0   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000
    
      Columns 11 through 20
    
             0         0         0         0         0         0         0         0         0         0
        0.0000   -0.0773   -0.1469   -0.2023   -0.2378   -0.2500   -0.2378   -0.2023   -0.1469   -0.0773
        0.0000   -0.1338   -0.2545   -0.3503   -0.4118   -0.4330   -0.4118   -0.3503   -0.2545   -0.1338
        0.0000   -0.1545   -0.2939   -0.4045   -0.4755   -0.5000   -0.4755   -0.4045   -0.2939   -0.1545
        0.0000   -0.1338   -0.2545   -0.3503   -0.4118   -0.4330   -0.4118   -0.3503   -0.2545   -0.1338
        0.0000   -0.0773   -0.1469   -0.2023   -0.2378   -0.2500   -0.2378   -0.2023   -0.1469   -0.0773
        0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000
       -0.0000    0.0773    0.1469    0.2023    0.2378    0.2500    0.2378    0.2023    0.1469    0.0773
       -0.0000    0.1338    0.2545    0.3503    0.4118    0.4330    0.4118    0.3503    0.2545    0.1338
       -0.0000    0.1545    0.2939    0.4045    0.4755    0.5000    0.4755    0.4045    0.2939    0.1545
       -0.0000    0.1338    0.2545    0.3503    0.4118    0.4330    0.4118    0.3503    0.2545    0.1338
       -0.0000    0.0773    0.1469    0.2023    0.2378    0.2500    0.2378    0.2023    0.1469    0.0773
       -0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000
    
      Column 21
    
             0
             0
             0
             0
             0
             0
             0
             0
             0
             0
             0
             0
             0
    
    
    z =
    
      Columns 1 through 10
    
             0         0         0         0         0         0         0         0         0         0
        0.0833    0.0833    0.0833    0.0833    0.0833    0.0833    0.0833    0.0833    0.0833    0.0833
        0.1667    0.1667    0.1667    0.1667    0.1667    0.1667    0.1667    0.1667    0.1667    0.1667
        0.2500    0.2500    0.2500    0.2500    0.2500    0.2500    0.2500    0.2500    0.2500    0.2500
        0.3333    0.3333    0.3333    0.3333    0.3333    0.3333    0.3333    0.3333    0.3333    0.3333
        0.4167    0.4167    0.4167    0.4167    0.4167    0.4167    0.4167    0.4167    0.4167    0.4167
        0.5000    0.5000    0.5000    0.5000    0.5000    0.5000    0.5000    0.5000    0.5000    0.5000
        0.5833    0.5833    0.5833    0.5833    0.5833    0.5833    0.5833    0.5833    0.5833    0.5833
        0.6667    0.6667    0.6667    0.6667    0.6667    0.6667    0.6667    0.6667    0.6667    0.6667
        0.7500    0.7500    0.7500    0.7500    0.7500    0.7500    0.7500    0.7500    0.7500    0.7500
        0.8333    0.8333    0.8333    0.8333    0.8333    0.8333    0.8333    0.8333    0.8333    0.8333
        0.9167    0.9167    0.9167    0.9167    0.9167    0.9167    0.9167    0.9167    0.9167    0.9167
        1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000
    
      Columns 11 through 20
    
             0         0         0         0         0         0         0         0         0         0
        0.0833    0.0833    0.0833    0.0833    0.0833    0.0833    0.0833    0.0833    0.0833    0.0833
        0.1667    0.1667    0.1667    0.1667    0.1667    0.1667    0.1667    0.1667    0.1667    0.1667
        0.2500    0.2500    0.2500    0.2500    0.2500    0.2500    0.2500    0.2500    0.2500    0.2500
        0.3333    0.3333    0.3333    0.3333    0.3333    0.3333    0.3333    0.3333    0.3333    0.3333
        0.4167    0.4167    0.4167    0.4167    0.4167    0.4167    0.4167    0.4167    0.4167    0.4167
        0.5000    0.5000    0.5000    0.5000    0.5000    0.5000    0.5000    0.5000    0.5000    0.5000
        0.5833    0.5833    0.5833    0.5833    0.5833    0.5833    0.5833    0.5833    0.5833    0.5833
        0.6667    0.6667    0.6667    0.6667    0.6667    0.6667    0.6667    0.6667    0.6667    0.6667
        0.7500    0.7500    0.7500    0.7500    0.7500    0.7500    0.7500    0.7500    0.7500    0.7500
        0.8333    0.8333    0.8333    0.8333    0.8333    0.8333    0.8333    0.8333    0.8333    0.8333
        0.9167    0.9167    0.9167    0.9167    0.9167    0.9167    0.9167    0.9167    0.9167    0.9167
        1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000    1.0000
    
      Column 21
    
             0
        0.0833
        0.1667
        0.2500
        0.3333
        0.4167
        0.5000
        0.5833
        0.6667
        0.7500
        0.8333
        0.9167
        1.0000
    
    >> surf(x,y,z)
    >> colormap(pink)
    >> pink
    
    ans =
    
        0.1179         0         0
        0.1959    0.1029    0.1029
        0.2507    0.1455    0.1455
        0.2955    0.1782    0.1782
        0.3343    0.2057    0.2057
        0.3691    0.2300    0.2300
        0.4009    0.2520    0.2520
        0.4303    0.2722    0.2722
        0.4579    0.2910    0.2910
        0.4839    0.3086    0.3086
        0.5085    0.3253    0.3253
        0.5320    0.3412    0.3412
        0.5546    0.3563    0.3563
        0.5762    0.3709    0.3709
        0.5971    0.3849    0.3849
        0.6172    0.3984    0.3984
        0.6367    0.4115    0.4115
        0.6557    0.4241    0.4241
        0.6741    0.4364    0.4364
        0.6920    0.4484    0.4484
        0.7094    0.4600    0.4600
        0.7265    0.4714    0.4714
        0.7431    0.4825    0.4825
        0.7594    0.4933    0.4933
        0.7664    0.5175    0.5040
        0.7732    0.5407    0.5143
        0.7800    0.5628    0.5245
        0.7868    0.5842    0.5345
        0.7935    0.6048    0.5443
        0.8001    0.6247    0.5540
        0.8067    0.6440    0.5634
        0.8133    0.6627    0.5727
        0.8197    0.6809    0.5819
        0.8262    0.6986    0.5909
        0.8325    0.7159    0.5998
        0.8389    0.7328    0.6086
        0.8452    0.7493    0.6172
        0.8514    0.7655    0.6257
        0.8576    0.7813    0.6341
        0.8637    0.7968    0.6424
        0.8698    0.8120    0.6506
        0.8759    0.8270    0.6587
        0.8819    0.8416    0.6667
        0.8879    0.8560    0.6746
        0.8938    0.8702    0.6824
        0.8997    0.8842    0.6901
        0.9056    0.8979    0.6977
        0.9114    0.9114    0.7052
        0.9172    0.9172    0.7272
        0.9230    0.9230    0.7485
        0.9287    0.9287    0.7692
        0.9344    0.9344    0.7893
        0.9400    0.9400    0.8090
        0.9456    0.9456    0.8282
        0.9512    0.9512    0.8469
        0.9567    0.9567    0.8653
        0.9623    0.9623    0.8832
        0.9677    0.9677    0.9008
        0.9732    0.9732    0.9181
        0.9786    0.9786    0.9351
        0.9840    0.9840    0.9517
        0.9894    0.9894    0.9681
        0.9947    0.9947    0.9842
        1.0000    1.0000    1.0000
    (2)运行结果如下:

            a、输入surf(x,y,z),显示图如下



        b、输入colormap(pink)命令后显示的图像



                           

  • 相关阅读:
    docker使用
    window版docker安装及配置
    mysql命令
    xshell
    git 命令
    分页器原理
    PCL-Kinfu编译手册
    cmake-add_definitions
    cmake-include_directories
    cmake-source_group
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13315623.html
Copyright © 2020-2023  润新知