2847
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
2313
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
2313
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
245
|
18 |
3369
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} fliplr (@var{x}) |
|
21 ## Return a copy of @var{x} with the order of the columns reversed. For |
3426
|
22 ## example, |
|
23 ## |
3369
|
24 ## @example |
|
25 ## @group |
|
26 ## fliplr ([1, 2; 3, 4]) |
|
27 ## @result{} 2 1 |
|
28 ## 4 3 |
|
29 ## @end group |
|
30 ## @end example |
5053
|
31 ## |
5448
|
32 ## Note that @code{fliplr} only work with 2-D arrays. To flip N-d arrays |
5053
|
33 ## use @code{flipdim} instead. |
5642
|
34 ## @seealso{flipud, flipdim, rot90, rotdim} |
3369
|
35 ## @end deftypefn |
4
|
36 |
2314
|
37 ## Author: jwe |
|
38 |
2311
|
39 function y = fliplr (x) |
4
|
40 |
|
41 if (nargin != 1) |
6046
|
42 print_usage (); |
4
|
43 endif |
|
44 |
4869
|
45 if (ndims (x) > 2) |
|
46 error ("fliplr: Only works with 2-D arrays") |
|
47 endif |
|
48 |
4
|
49 nc = columns (x); |
|
50 y = x (:, nc:-1:1); |
|
51 |
|
52 endfunction |