This is a static copy of a profile report

Home

grid (Calls: 2, Time: 0.010 s)
Generated 16-Jul-2020 17:08:38 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/graph2d/grid.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
surffunction2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
22
isaxarr=matlab.graphics.chart....
20.003 s30.0%
81
matlab.graphics.internal.markF...
20.001 s7.4%
143
set(ax,zgrid, 'on');
20.001 s6.7%
42
if matlab.graphics.internal.is...
20.001 s6.2%
141
ygrid, 'on');
20.001 s5.6%
All other lines  0.004 s44.1%
Totals  0.010 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
objArrayDispatchfunction20.002 s19.8%
markFigurefunction20.000 s4.7%
isCharOrStringfunction20.000 s3.7%
Self time (built-ins, overhead, etc.)  0.007 s71.8%
Totals  0.010 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function156
Non-code lines (comments, blank lines)35
Code lines (lines that can run)121
Code lines that did run42
Code lines that did not run79
Coverage (did run/can run)34.71 %
Function listing
time 
Calls 
 line
   1 
function grid(varargin)
   2 
%GRID   Grid lines.
   3 
%   GRID ON adds major grid lines to the current axes.
   4 
%   GRID OFF removes major and minor grid lines from the current axes. 
   5 
%   GRID MINOR toggles the minor grid lines of the current axes.
   6 
%   GRID, by itself, toggles the major grid lines of the current axes.
   7 
%   GRID(AX,...) uses axes AX instead of the current axes.
   8 
%
   9 
%   GRID sets the XGrid, YGrid, and ZGrid properties of
  10 
%   the current axes. If the axes is a polar axes then GRID sets
  11 
%   the ThetaGrid and RGrid properties. If the axes is a geoaxes, then GRID
  12 
%   sets the Grid property.
  13 
%
  14 
%   AX.XMinorGrid = 'on' turns on the minor grid.
  15 
%
  16 
%   See also TITLE, XLABEL, YLABEL, ZLABEL, AXES, PLOT, BOX, POLARAXES.
  17 

  18 
%   Copyright 1984-2019 The MathWorks, Inc.
  19 

  20 
% To ensure the correct current handle is taken in all situations.
  21 

  0.003 
      2 
  22
isaxarr=matlab.graphics.chart.internal.objArrayDispatch(@grid,varargin{:}); 
< 0.001 
      2 
  23
if isaxarr 
  24 
    return
< 0.001 
      2 
  25
end 
  26 

< 0.001 
      2 
  27
opt_grid = 0; 
< 0.001 
      2 
  28
if nargin == 0 
  29 
    ax = gca;
  30 
    
  31 
    % Chart subclass support
  32 
    if isa(ax,'matlab.graphics.chart.Chart')
  33 
        grid(ax);
  34 
        return
  35 
    end
< 0.001 
      2 
  36
else 
< 0.001 
      2 
  37
    arg1=varargin{1}; 
  38 
    
< 0.001 
      2 
  39
    if isempty(arg1) 
  40 
        opt_grid = lower(arg1);
< 0.001 
      2 
  41
    end 
< 0.001 
      2 
  42
    if matlab.graphics.internal.isCharOrString(arg1) 
  43 
        % string input (check for valid option later)
  44 
        if nargin == 2
  45 
            error(message('MATLAB:grid:FirstArgAxes'))
  46 
        end
  47 
        ax = gca;        
  48 
        opt_grid = lower(arg1);
  49 
        
  50 
        % Chart subclass support
  51 
        if isa(ax,'matlab.graphics.chart.Chart')
  52 
            grid(ax,opt_grid);
  53 
            return
  54 
        end
< 0.001 
      2 
  55
    else 
< 0.001 
      2 
  56
        if ~any(isgraphics(arg1,'axes') ... 
      2 
  57
                | isgraphics(arg1,'polaraxes') ... 
      2 
  58
                | isgraphics(arg1,'geoaxes'),'all') 
  59 
            error(message('MATLAB:grid:FirstArgAxes'));
< 0.001 
      2 
  60
        end 
< 0.001 
      2 
  61
        ax = arg1; 
  62 
        
  63 
        % check for string option
< 0.001 
      2 
  64
        if nargin == 2 
< 0.001 
      2 
  65
            opt_grid = lower(varargin{2}); 
< 0.001 
      2 
  66
        end 
< 0.001 
      2 
  67
    end 
< 0.001 
      2 
  68
end 
  69 

< 0.001 
      2 
  70
if (isempty(opt_grid)) 
  71 
    error(message('MATLAB:grid:UnknownOption'));
< 0.001 
      2 
  72
end 
< 0.001 
      2 
  73
names = get(ax,'DimensionNames'); 
< 0.001 
      2 
  74
xgrid = [names{1} 'Grid']; 
< 0.001 
      2 
  75
ygrid = [names{2} 'Grid']; 
< 0.001 
      2 
  76
zgrid = [names{3} 'Grid']; 
< 0.001 
      2 
  77
xminorgrid = [names{1} 'MinorGrid']; 
< 0.001 
      2 
  78
yminorgrid = [names{2} 'MinorGrid']; 
< 0.001 
      2 
  79
zminorgrid = [names{3} 'MinorGrid']; 
  80 

< 0.001 
      2 
  81
matlab.graphics.internal.markFigure(ax); 
  82 

  83 
%---Check for bypass option
< 0.001 
      2 
  84
if isappdata(ax,'MWBYPASS_grid') 
  85 
   mwbypass(ax,'MWBYPASS_grid',opt_grid);
< 0.001 
      2 
  86
elseif isgraphics(ax,'geoaxes') 
  87 
    % geoaxes only has 1 Grid property and does not have a minor grid
  88 
    if isequal(opt_grid, 0)
  89 
        if (strcmp(get(ax,'Grid'),'off'))
  90 
            set(ax,'Grid','on');
  91 
        else
  92 
            set(ax,'Grid','off');
  93 
        end
  94 
    elseif (strcmp(opt_grid, 'on'))
  95 
        set(ax,'Grid','on');
  96 
    elseif (strcmp(opt_grid, 'off'))
  97 
        set(ax,'Grid','off');
  98 
    elseif (strcmp(opt_grid, 'minor'))
  99 
        error(message('MATLAB:Chart:UnsupportedArgument','grid','geoaxes'));
 100 
    else
 101 
        error(message('MATLAB:grid:UnknownOption'));
 102 
    end
< 0.001 
      2 
 103
elseif isequal(opt_grid, 0) 
 104 
    if (strcmp(get(ax,xgrid),'off'))
 105 
        set(ax,xgrid,'on');
 106 
    else
 107 
        set(ax,xgrid,'off');
 108 
    end
 109 
    if (strcmp(get(ax,ygrid),'off'))
 110 
        set(ax,ygrid,'on');
 111 
    else
 112 
        set(ax,ygrid,'off');
 113 
    end
 114 
    if hasZProperties(handle(ax))
 115 
        if (strcmp(get(ax,zgrid),'off'))
 116 
            set(ax,zgrid,'on');
 117 
        else
 118 
            set(ax,zgrid,'off');
 119 
        end
 120 
    end
< 0.001 
      2 
 121
elseif (strcmp(opt_grid, 'minor')) 
 122 
    if (strcmp(get(ax,xminorgrid),'off'))
 123 
        set(ax,xminorgrid,'on');
 124 
    else
 125 
        set(ax,xminorgrid,'off');
 126 
    end
 127 
    if (strcmp(get(ax,yminorgrid),'off'))
 128 
        set(ax,yminorgrid,'on');
 129 
    else
 130 
        set(ax,yminorgrid,'off');
 131 
    end
 132 
    if hasZProperties(handle(ax))
 133 
        if (strcmp(get(ax,zminorgrid),'off'))
 134 
            set(ax,zminorgrid,'on');
 135 
        else
 136 
            set(ax,zminorgrid,'off');
 137 
        end
 138 
    end
< 0.001 
      2 
 139
elseif (strcmp(opt_grid, 'on')) 
< 0.001 
      2 
 140
    set(ax,xgrid, 'on', ... 
      2 
 141
           ygrid, 'on'); 
< 0.001 
      2 
 142
    if hasZProperties(handle(ax)) 
< 0.001 
      2 
 143
        set(ax,zgrid, 'on'); 
< 0.001 
      2 
 144
    end 
 145 
elseif (strcmp(opt_grid, 'off'))
 146 
    set(ax,xgrid, 'off', ...
 147 
           ygrid, 'off', ...
 148 
           xminorgrid, 'off', ...
 149 
           yminorgrid, 'off');
 150 
    if hasZProperties(handle(ax))
 151 
        set(ax,zgrid, 'off');
 152 
        set(ax,zminorgrid, 'off');
 153 
    end
 154 
else
 155 
    error(message('MATLAB:grid:UnknownOption'));
< 0.001 
      2 
 156
end 

Other subfunctions in this file are not included in this listing.