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 | |
---|
1 | function 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 |
---|
6 | L = length(A); |
---|
7 | if iscell(A) |
---|
8 | z = cell(size(A)); |
---|
9 | for i=1:L |
---|
10 | z{i} = A{L-i+1}; |
---|
11 | end |
---|
12 | elseif isnumeric(A) |
---|
13 | z = zeros(size(A)); |
---|
14 | for i=1:L |
---|
15 | z(i) = A(L-i+1); |
---|
16 | end |
---|
17 | elseif ischar(A) |
---|
18 | z = char(reverse(double(A))); |
---|
19 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.