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.