changeset 9160:11e0f0e8ff00

fix range
author Jaroslav Hajek <highegg@gmail.com>
date Thu, 30 Apr 2009 20:52:07 +0200
parents c07cbffb82e3
children 406ed43c0233
files scripts/ChangeLog scripts/statistics/base/range.m
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Wed Apr 29 08:16:48 2009 +0200
+++ b/scripts/ChangeLog	Thu Apr 30 20:52:07 2009 +0200
@@ -1,3 +1,7 @@
+2009-04-30  Jaroslav Hajek <highegg@gmail.com>
+
+	* statistics/base/range.m: Fix behavior when dim is specified.
+
 2009-04-28  Ben Abbott <bpabbott@mac.com>
 
 	* plot/print.m: Fix typo: 'gswin23c' -> 'gswin32c'. Suppress stderr
--- a/scripts/statistics/base/range.m	Wed Apr 29 08:16:48 2009 +0200
+++ b/scripts/statistics/base/range.m	Thu Apr 30 20:52:07 2009 +0200
@@ -1,5 +1,6 @@
 ## Copyright (C) 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2005, 2006,
 ##               2007 Kurt Hornik
+## Copyright (C) 2009 Jaroslav Hajek
 ##
 ## This file is part of Octave.
 ##
@@ -32,12 +33,14 @@
 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
 ## Description: Compute range
 
-function y = range (x, varargin)
+function y = range (x, dim)
 
-  if (nargin != 1 && nargin != 2)
+  if (nargin == 1)
+    y = max (x) - min (x);
+  elseif (nargin == 2)
+    y = max (x, dim) - min (x, dim);
+  else
     print_usage ();
   endif
 
-  y = max (x, varargin{:}) - min (x, varargin{:});
-
 endfunction