3200
|
1 ## Copyright (C) 1995, 1996, 1997 Kurt Hornik |
3426
|
2 ## |
3922
|
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. |
3426
|
9 ## |
3922
|
10 ## Octave is distributed in the hope that it will be useful, but |
3200
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3426
|
13 ## General Public License for more details. |
|
14 ## |
3200
|
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/>. |
3200
|
18 |
3453
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} range (@var{x}) |
4848
|
21 ## @deftypefnx {Function File} {} range (@var{x}, @var{dim}) |
3453
|
22 ## If @var{x} is a vector, return the range, i.e., the difference |
|
23 ## between the maximum and the minimum, of the input data. |
3200
|
24 ## |
3453
|
25 ## If @var{x} is a matrix, do the above for each column of @var{x}. |
4847
|
26 ## |
|
27 ## If the optional argument @var{dim} is supplied, work along dimension |
|
28 ## @var{dim}. |
3453
|
29 ## @end deftypefn |
3426
|
30 |
5428
|
31 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
3456
|
32 ## Description: Compute range |
3200
|
33 |
5096
|
34 function y = range (x, varargin) |
3426
|
35 |
4847
|
36 if (nargin != 1 && nargin != 2) |
6046
|
37 print_usage (); |
3200
|
38 endif |
|
39 |
4847
|
40 y = max (x, varargin{:}) - min (x, varargin{:}); |
3426
|
41 |
3200
|
42 endfunction |