source: MML/trunk/at/lattice/reverse.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 417 bytes
Line 
1function z = reverse(A)
2%REVERSE reverses the order of elements in a one-dimensional MATLAB ARRAY
3%
4% ARRAY2 = REVERSE(ARRAY1)
5%   ARRAY1 can be numeric, char (string), or cell array
6L = length(A);
7if iscell(A)
8   z = cell(size(A));
9   for i=1:L
10      z{i} = A{L-i+1};
11   end
12elseif isnumeric(A)
13   z = zeros(size(A));
14   for i=1:L
15      z(i) = A(L-i+1);
16   end
17elseif ischar(A)
18    z = char(reverse(double(A)));
19end
Note: See TracBrowser for help on using the repository browser.