This is a static copy of a profile report

Home

Function details for colormapThis is a static copy of a profile report

Home

colormap (Calls: 2, Time: 0.008 s)
Generated 01-May-2020 20:23:07 using performance time.
function in file /Applications/MATLAB_R2018a.app/toolbox/matlab/graph3d/colormap.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
OC3function2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
46
elseif (isCharOrString(arg1))|...
20.002 s21.6%
98
if min(min(arg)) < 0 || max...
20.001 s19.0%
102
set(figH, 'Colormap', arg);   ...
20.001 s11.3%
94
if ~isempty(arg)
20.001 s10.9%
52
if (isCharOrString(arg1))
20.001 s8.7%
All other lines  0.002 s28.6%
Totals  0.008 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
isCharOrStringfunction60.000 s6.2%
Self time (built-ins, overhead, etc.)  0.007 s93.8%
Totals  0.008 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function106
Non-code lines (comments, blank lines)48
Code lines (lines that can run)58
Code lines that did run19
Code lines that did not run39
Coverage (did run/can run)32.76 %
Function listing
time 
Calls 
 line
   1 
function map = colormap(arg1,arg2)
   2 
%COLORMAP Color look-up table.
   3 
%   COLORMAP(MAP) sets the current figure's colormap to MAP.
   4 
%   COLORMAP('default') sets the current figure's colormap to
   5 
%   the root's default, whose setting is PARULA.
   6 
%   MAP = COLORMAP returns the three-column matrix of RGB triplets defining 
   7 
%   the colormap for the current figure.
   8 
%   COLORMAP(FIG,...) sets the colormap for the figure specified by FIG.
   9 
%   COLORMAP(AX,...) sets the colormap for the axes specified by AX. 
  10 
%   Each axes within a figure can have a unique colormap. After you set
  11 
%   an axes colormap, changing the figure colormap does not affect the axes.
  12 
%   MAP = COLORMAP(FIG) returns the colormap for the figure specified by FIG.
  13 
%   MAP = COLORMAP(AX) returns the colormap for the axes specified by AX.
  14 
%
  15 
%   A color map matrix may have any number of rows, but it must have
  16 
%   exactly 3 columns.  Each row is interpreted as a color, with the
  17 
%   first element specifying the intensity of red light, the second
  18 
%   green, and the third blue.  Color intensity can be specified on the
  19 
%   interval 0.0 to 1.0.
  20 
%   For example, [0 0 0] is black, [1 1 1] is white,
  21 
%   [1 0 0] is pure red, [.5 .5 .5] is gray, and
  22 
%   [127/255 1 212/255] is aquamarine.
  23 
%
  24 
%   Graphics objects that use pseudocolor  -- SURFACE and PATCH objects,
  25 
%   which are created by the functions MESH, SURF, and PCOLOR -- map
  26 
%   a color matrix, C, whose values are in the range [Cmin, Cmax],
  27 
%   to an array of indices, k, in the range [1, m].
  28 
%   The values of Cmin and Cmax are either min(min(C)) and max(max(C)),
  29 
%   or are specified by CAXIS.  The mapping is linear, with Cmin
  30 
%   mapping to index 1 and Cmax mapping to index m.  The indices are
  31 
%   then used with the colormap to determine the color associated
  32 
%   with each matrix element.  See CAXIS for details.
  33 
%
  34 
%   Type HELP GRAPH3D to see a number of useful colormaps.
  35 
%
  36 
%   COLORMAP is a function that sets the Colormap property of a figure.
  37 
%
  38 
%   See also HSV, CAXIS, SPINMAP, BRIGHTEN, RGBPLOT, FIGURE, COLORMAPEDITOR.
  39 

  40 
%   Copyright 1984-2017 The MathWorks, Inc.
  41 

  42 
import matlab.graphics.internal.*;
< 0.001 
      2 
  43
arg = 0; 
< 0.001 
      2 
  44
if (nargin == 0) 
  45 
    figH = gcf;
  0.002 
      2 
  46
elseif (isCharOrString(arg1))||(length(arg1) > 1)||isempty(arg1) 
  47 
    % string input (check for valid option later)
< 0.001 
      2 
  48
    if (nargin == 2) 
  49 
        error(message('MATLAB:colormap:InvalidFirstArgument'));
  50 
    end
< 0.001 
      2 
  51
    figH = gcf; 
< 0.001 
      2 
  52
    if (isCharOrString(arg1)) 
  53 
        arg = lower(arg1);
< 0.001 
      2 
  54
    else 
< 0.001 
      2 
  55
        arg = arg1; 
< 0.001 
      2 
  56
    end 
  57 
else
  58 
    % figH can be any object that can contain a colormap
  59 
    figH = getMapContainer(arg1);
  60 
    if isempty(figH)
  61 
        error(message('MATLAB:colormap:NeedScalarHandle'));
  62 
    end
  63 
            
  64 
    % check for string option
  65 
    if nargin == 2
  66 
        if (isCharOrString(arg2))
  67 
            arg = lower(arg2);
  68 
        else
  69 
            arg = arg2;
  70 
        end
  71 
    end
< 0.001 
      2 
  72
end 
  73 

< 0.001 
      2 
  74
if isequal(arg,0) 
  75 
    map = get(figH, 'Colormap');
  76 
    return
  77 
end
< 0.001 
      2 
  78
if isCharOrString(arg) 
  79 
    % For indexing purpose, convert arg to char.
  80 
    arg = char(arg);
  81 
    if strcmp(arg,'default')        
  82 
        fig = ancestor(figH,'figure');
  83 
        defaultMap = get(fig,'defaultfigureColormap');
  84 
        set(figH,'Colormap',defaultMap);
  85 
        return;
  86 
    end
  87 
    k = min(strfind(arg,'('));
  88 
    if ~isempty(k)
  89 
        arg = feval(arg(1:k-1),str2double(arg(k+1:end-1)));
  90 
    else
  91 
        arg = feval(arg);
  92 
    end
  93 
end
< 0.001 
      2 
  94
if ~isempty(arg) 
< 0.001 
      2 
  95
    if (size(arg,2) ~= 3) 
  96 
        error(message('MATLAB:colormap:InvalidNumberColumns'));
  97 
    end
  0.001 
      2 
  98
    if min(min(arg)) < 0 || max(max(arg)) > 1 
  99 
        error(message('MATLAB:colormap:InvalidInputRange'))
 100 
    end
< 0.001 
      2 
 101
end 
< 0.001 
      2 
 102
    set(figH, 'Colormap', arg);     
< 0.001 
      2 
 103
    if nargout == 1 
 104 
        map = get(figH, 'Colormap');
 105 
    end
< 0.001 
      2 
 106
end