This is a static copy of a profile report

Home

rulerFunctions (Calls: 2, Time: 0.008 s)
Generated 16-Jul-2020 17:08:38 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/graphics/axis/+matlab/+graphics/+internal/+ruler/rulerFunctions.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
ylimfunction2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
9
[axle, ruler, family, prop, mo...
20.002 s23.8%
42
elseif nargs > 0 &&...
20.001 s13.4%
208
matlab.graphics.internal.markF...
20.001 s8.1%
132
if ~isempty(mode) && m...
20.001 s6.9%
79
elseif isempty(ruler) &&am...
20.000 s5.9%
All other lines  0.003 s41.8%
Totals  0.008 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
rulerFunctions>parseFunctionNamesubfunction20.001 s15.9%
...isa(ax,'matlab.graphics.chart.Chart')anonymous function20.000 s4.2%
markFigurefunction20.000 s3.7%
isCharOrStringfunction20.000 s0.2%
Self time (built-ins, overhead, etc.)  0.006 s76.1%
Totals  0.008 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function210
Non-code lines (comments, blank lines)82
Code lines (lines that can run)128
Code lines that did run40
Code lines that did not run88
Coverage (did run/can run)31.25 %
Function listing
time 
Calls 
 line
   1 
function out = rulerFunctions(func, numargsout, args)
   2 
% This function is undocumented and may change in a future release.
   3 

   4 
%   Copyright 2016-2018 The MathWorks, Inc.
   5 

   6 
% --- Input parsing and error checking ---
   7 

   8 
% Parse the function name into pieces.
  0.002 
      2 
   9
[axle, ruler, family, prop, mode] = parseFunctionName(func); 
  10 

  11 
% Count how many arguments were passed into the parent function
< 0.001 
      2 
  12
nargs = numel(args); 
  13 

  14 
% Make sure we have 0-2 input arguments to the calling function.
< 0.001 
      2 
  15
if nargs > 2 
  16 
    throwAsCaller(MException(message('MATLAB:narginchk:tooManyInputs')))
< 0.001 
      2 
  17
end 
  18 

  19 
% Make sure we have either 0 or 1 output arguments to the calling function.
< 0.001 
      2 
  20
if numargsout > 1 
  21 
    throwAsCaller(MException(message('MATLAB:nargoutchk:tooManyOutputs')));
< 0.001 
      2 
  22
end 
  23 

  24 
% Helper function to validate the acceptable types of axes.
  25 
% Axes types are listed separately to prevent mixed vectors.
< 0.001 
      2 
  26
isAxes = @(ax) isa(ax,'matlab.graphics.axis.Axes') || ... 
  27 
    isa(ax, 'matlab.graphics.axis.PolarAxes') || ...
  28 
    isa(ax, 'matlab.graphics.axis.GeographicAxes') || ...
  29 
    isa(ax, 'matlab.ui.control.UIAxes') || ...
  30 
    isa(ax, 'matlab.graphics.illustration.ColorBar') || ...
  31 
    isa(ax, 'matlab.graphics.chart.Chart');
  32 

  33 
% Parse the input arguments to look for an Axes.
< 0.001 
      2 
  34
if nargs > 0 && isscalar(args{1}) && (isgraphics(args{1},'axes') || ... 
  35 
        isgraphics(args{1},'polaraxes') || ...
  36 
        isgraphics(args{1},'geoaxes') || ...
  37 
        isgraphics(args{1},'colorbar'))
  38 
    % The first input is a single axes or colorbar.
  39 
    ax = handle(args{1});
  40 
    args = args(2:end);
  41 
    nargs = nargs - 1;
  0.001 
      2 
  42
elseif nargs > 0 && ~isempty(args{1}) && isAxes(args{1}) && all(isvalid(args{1}(:))) 
  43 
    % The first input is an array of axes, charts, or colorbars.
  44 
    ax = args{1}(:);
  45 
    args = args(2:end);
  46 
    nargs = nargs - 1;
< 0.001 
      2 
  47
elseif nargs > 0 && isa(args{1},'matlab.graphics.Graphics') 
  48 
    if ~isempty(args{1}) && all(isvalid(args{1}(:))) && all(arrayfun(isAxes,args{1}(:)))
  49 
        % Mixed list of different types of axes.
  50 
        throwAsCaller(MException(message('MATLAB:rulerFunctions:MixedAxesVector')));
  51 
    else
  52 
        % Empty vector or one of the objects is not an axes or has been deleted.
  53 
        throwAsCaller(MException(message('MATLAB:rulerFunctions:InvalidObject')));
  54 
    end
< 0.001 
      2 
  55
elseif nargs == 2 
  56 
    % If we have two input arguments and the first input is not a valid
  57 
    % graphics object, then the user specified an invalid syntax.
  58 
    throwAsCaller(MException(message('MATLAB:rulerFunctions:InvalidAxes')));
< 0.001 
      2 
  59
else 
  60 
    % No axes handle provided, so use the current Axes.
< 0.001 
      2 
  61
    ax = gca; 
< 0.001 
      2 
  62
end 
  63 

< 0.001 
      2 
  64
fh = []; 
< 0.001 
      2 
  65
if isa(ax,'matlab.graphics.chart.Chart') 
  66 
    % Subclasses of matlab.graphics.chart.Chart will implement individual
  67 
    % ruler functions if they are supported.
  68 
    
  69 
    % Error if the function does not exist as a method on the chart.
  70 
    if(~isPublicMethod(ax,func))
  71 
        throwAsCaller(MException(message('MATLAB:Chart:UnsupportedConvenienceFunction', func, ax(1).Type)));
  72 
    end
  73 
    
  74 
    % Store a function handle for use later.
  75 
    fh = str2func(func);
  76 
    ruler = ax;
< 0.001 
      2 
  77
elseif isa(ax,'matlab.graphics.axis.GeographicAxes') 
  78 
    throwAsCaller(MException(message('MATLAB:Chart:UnsupportedConvenienceFunction', func, ax(1).Type)));
< 0.001 
      2 
  79
elseif isempty(ruler) && all(isprop(ax,prop)) 
  80 
    % Limits are set on the Axes directly so that PreSet/PostSet events are
  81 
    % triggered, and for compatibility with colorbars.
< 0.001 
      2 
  82
    ruler = ax; 
  83 
elseif all(isprop(ax,ruler))
  84 
    % All other properties are set on the Rulers directly.
  85 
    ruler = vertcat(ax(:).(ruler));
  86 
elseif isa(ax, 'matlab.graphics.illustration.ColorBar')
  87 
    % Colorbars support the xlim and ylim commands only for compatibility.
  88 
    throwAsCaller(MException(message('MATLAB:rulerFunctions:ColorBar',func)));
  89 
elseif isa(ax, 'matlab.ui.control.UIAxes')
  90 
    % UIAxes only supports X and Y
  91 
    throwAsCaller(MException(message('MATLAB:rulerFunctions:UIAxes',func)));
  92 
else
  93 
    % The axes specified is not compatible with this function (such as
  94 
    % calling xlim on a PolarAxes).
  95 
    throwAsCaller(axesTypeMismatch(axle, family));
< 0.001 
      2 
  96
end 
  97 

  98 
% Filter out tickformat functions on CategoricalRuler
< 0.001 
      2 
  99
if strcmp(family,'tickformat') && ... 
 100 
        any(isa(ruler,'matlab.graphics.axis.decorator.CategoricalRuler'))
 101 
    throwAsCaller(MException(message('MATLAB:rulerFunctions:Categorical',func)));
< 0.001 
      2 
 102
end 
 103 

 104 
% --- Get/Set the property based on the inputs ---
 105 

 106 
% Initialize output variables.
< 0.001 
      2 
 107
out = cell(0); 
 108 

< 0.001 
      2 
 109
if nargs == 0 
 110 
    % If no additional inputs were provided, return the current value of
 111 
    % the property.
 112 
    if ~isempty(fh)
 113 
        % Call the chart specific implementation.
 114 
        try
 115 
            out{1} = fh(ruler, args{:});
 116 
        catch err
 117 
            throwAsCaller(err);
 118 
        end
 119 
    elseif isscalar(ruler)
 120 
        out{1} = ruler.(prop);
 121 
    else
 122 
        out{1} = {ruler(:).(prop)}';
 123 
    end
 124 
    return
< 0.001 
      2 
 125
end 
 126 

 127 
% Grab the value from the remaining input arguments.
< 0.001 
      2 
 128
val = args{1}; 
 129 

 130 
% If the property has a mode setting, check if the user is trying to
 131 
% change or query the mode.
< 0.001 
      2 
 132
if ~isempty(mode) && matlab.graphics.internal.isCharOrString(val) 
 133 
    switch lower(val)
 134 
        case 'mode'
 135 
            % The user requested the current property mode
 136 
            if ~isempty(fh)
 137 
                % Call the chart specific implementation.
 138 
                try
 139 
                    out{1} = fh(ruler, 'mode');
 140 
                catch err
 141 
                    throwAsCaller(err);
 142 
                end
 143 
            elseif isscalar(ruler)
 144 
                out{1} = ruler.(mode);
 145 
            else
 146 
                out{1} = {ruler(:).(mode)}';
 147 
            end
 148 
            return
 149 
        case {'auto','manual'}
 150 
            % The user is trying to set the property mode
 151 
            
 152 
            if isempty(fh)
 153 
                % No output arguments are returned when you set the
 154 
                % property mode.
 155 
                if numargsout > 0
 156 
                    throwAsCaller(MException(message('MATLAB:nargoutchk:tooManyOutputs')));
 157 
                end
 158 

 159 
                % Set the mode
 160 
                set(ruler,mode,val);
 161 
                
 162 
                % This command notifies the Live Editor of potential changes to the figure.
 163 
                matlab.graphics.internal.markFigure(ax);
 164 
                return
 165 
            end
 166 
    end
< 0.001 
      2 
 167
end 
 168 

 169 
% Call the chart specific implementation of the ruler function. Use the
 170 
% same number of outputs to defer error handling to the method.
< 0.001 
      2 
 171
if ~isempty(fh) 
 172 
    out = cell(1,numargsout);
 173 
    try
 174 
        if numargsout == 0
 175 
            fh(ax,val);
 176 
        else
 177 
            [out{1:nargout}] = fh(ax,val);
 178 
        end
 179 
    catch err
 180 
        throwAsCaller(err);
 181 
    end
 182 
    return
< 0.001 
      2 
 183
end 
 184 

 185 
% No output arguments are returned when you set the property.
< 0.001 
      2 
 186
if numargsout > 0 
 187 
    throwAsCaller(MException(message('MATLAB:nargoutchk:tooManyOutputs')));
< 0.001 
      2 
 188
end 
 189 

 190 
% Try to set the property to the specified value.
< 0.001 
      2 
 191
try 
< 0.001 
      2 
 192
    switch family 
< 0.001 
      2 
 193
        case {'lim','ticks','tickangle'} 
< 0.001 
      2 
 194
            set(ruler,prop,val); 
 195 
        case 'ticklabels'
 196 
            matlab.graphics.internal.ruler.setTickLabel(ruler, val);
 197 
        case 'tickformat'
 198 
            matlab.graphics.internal.ruler.setTickFormat(ruler, val);
< 0.001 
      2 
 199
    end 
 200 
catch err
 201 
    % Check for recognized errors and replace them with custom error
 202 
    % messages specific to the convenience function.
 203 
    err = swapKnownErrorIDs(err, axle, val);
 204 
    throwAsCaller(err);
< 0.001 
      2 
 205
end 
 206 

 207 
% This command notifies the Live Editor of potential changes to the figure.
< 0.001 
      2 
 208
matlab.graphics.internal.markFigure(ax); 
 209 

< 0.001 
      2 
 210
end 

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