This is a static copy of a profile report

Home

flip (Calls: 182, Time: 0.015 s)
Generated 16-Jul-2020 17:08:51 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/elmat/+matlab/+internal/+builtinhelper/flip.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
flipudfunction182
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
46
y = x(v{:});
1740.005 s32.3%
42
v(1:max(dim,ndims(x))) = {':'}...
1740.003 s18.0%
44
v{dim} = dimsize:-1:1;
1740.002 s14.1%
33
dim = matlab.internal.math.get...
1820.002 s13.5%
37
if dimsize <= 1 && ...
1820.001 s5.4%
All other lines  0.002 s16.6%
Totals  0.015 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function47
Non-code lines (comments, blank lines)31
Code lines (lines that can run)16
Code lines that did run12
Code lines that did not run4
Coverage (did run/can run)75.00 %
Function listing
time 
Calls 
 line
   1 
function y = flip(x,dim)
   2 
%FLIP Flip the order of elements
   3 
%   Y = FLIP(X) returns a vector Y with the same dimensions as X, but with the
   4 
%   order of elements flipped. If X is a matrix, each column is flipped 
   5 
%   vertically. For N-D arrays, FLIP(X) operates on the first
   6 
%   nonsingleton dimension.
   7 
%
   8 
%   FLIP(X,DIM) works along the dimension DIM.
   9 
%
  10 
%   For example, FLIP(X) where
  11 
%
  12 
%       X = 1 4  produces  3 6
  13 
%           2 5            2 5
  14 
%           3 6            1 4
  15 
%
  16 
%
  17 
%   Class support for input X:
  18 
%      float: double, single
  19 
%      integers: uint8, int8, uint16, int16, uint32, int32, uint64, int64
  20 
%      char, logical
  21 
%
  22 
%   See also FLIPLR, FLIPUD, ROT90, PERMUTE.
  23 

  24 
%   Copyright 1984-2018 The MathWorks, Inc.
  25 

  26 
% Argument parsing
< 0.001 
    182 
  27
if nargin == 1 
  28 
    dim = find(size(x)~=1,1,'first'); % Find leading singleton dimensions
  29 
    if isempty(dim) % scalar case
  30 
        dim = 2;
  31 
    end
< 0.001 
    182 
  32
else 
  0.002 
    182 
  33
    dim = matlab.internal.math.getdimarg(dim); 
< 0.001 
    182 
  34
end 
  35 

< 0.001 
    182 
  36
dimsize = size(x,dim); 
< 0.001 
    182 
  37
if dimsize <= 1 && (isreal(x) || ~isnumeric(x)) 
  38 
    % No-op.
< 0.001 
      8 
  39
    y = x; 
< 0.001 
    174 
  40
else 
  41 
    % Create the index that will transform x.
  0.003 
    174 
  42
    v(1:max(dim,ndims(x))) = {':'}; 
  43 
    % Flip dimension dim.
  0.002 
    174 
  44
    v{dim} = dimsize:-1:1; 
  45 
    % Index with v.
  0.005 
    174 
  46
    y = x(v{:}); 
< 0.001 
    182 
  47
end 

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