This is a static copy of a profile report

Home

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

Home

flip (Calls: 15, Time: 0.001 s)
Generated 28-Jun-2020 10:10:23 using performance time.
function in file /Applications/MATLAB_R2018a.app/toolbox/matlab/elmat/+matlab/+internal/+builtinhelper/flip.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
flipudfunction15
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
34
if ~(isscalar(dim) && ...
150.000 s30.0%
39
dimsize = size(x,dim);
150.000 s25.2%
40
if (dimsize <= 1)
150.000 s11.0%
50
end
150.000 s1.7%
28
if nargin == 1
150.000 s0.3%
All other lines  0.000 s31.7%
Totals  0.001 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function50
Non-code lines (comments, blank lines)31
Code lines (lines that can run)19
Code lines that did run9
Code lines that did not run10
Coverage (did run/can run)47.37 %
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-2013 The MathWorks, Inc.
  25 

  26 
% Argument parsing
< 0.001 
     15 
  27
narginchk(1,2); 
< 0.001 
     15 
  28
if nargin == 1 
  29 
    dim = find(size(x)~=1,1,'first'); % Find leading singleton dimensions
  30 
    if isempty(dim) % scalar case
  31 
        dim = 2;
  32 
    end
< 0.001 
     15 
  33
else 
< 0.001 
     15 
  34
    if ~(isscalar(dim) && dim > 0 && isfinite(dim) && floor(dim)==dim) 
  35 
        error(message('MATLAB:getdimarg:dimensionMustBePositiveInteger'));
  36 
    end
< 0.001 
     15 
  37
end 
  38 

< 0.001 
     15 
  39
dimsize = size(x,dim); 
< 0.001 
     15 
  40
if (dimsize <= 1) 
  41 
    % No-op.
< 0.001 
     15 
  42
    y = x; 
  43 
else
  44 
    % Create the index that will transform x.
  45 
    v(1:ndims(x)) = {':'};
  46 
    % Flip dimension dim.
  47 
    v{dim} = dimsize:-1:1;
  48 
    % Index with v.
  49 
    y = x(v{:});
< 0.001 
     15 
  50
end 

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