changeset 5746:e4e93452fd3e

[project @ 2006-04-06 20:46:31 by jwe]
author jwe
date Thu, 06 Apr 2006 20:46:31 +0000
parents 0559ebb94bf0
children b09d4d0f5b63
files scripts/ChangeLog scripts/plot/hist.m
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Apr 06 20:33:41 2006 +0000
+++ b/scripts/ChangeLog	Thu Apr 06 20:46:31 2006 +0000
@@ -1,3 +1,7 @@
+2006-04-06  Olli Saarela  <olli.saarela@kcl.fi>
+
+	* plot/hist.m: Ignore NaN in inputs.
+
 2006-04-06  Keith Goodman  <kwgoodman@gmail.com>
 
 	* miscellaneous/mkoctfile.m: Doc string fix.
--- a/scripts/plot/hist.m	Thu Apr 06 20:33:41 2006 +0000
+++ b/scripts/plot/hist.m	Thu Apr 06 20:46:31 2006 +0000
@@ -97,7 +97,7 @@
     for i = 1:n-1
       chist(i+1,:) = sum (y <= cutoff(i));
     endfor
-    chist(n+1,:) = rows (y);
+    chist(n+1,:) = sum (! isnan (y));
   else
     ## The following algorithm works fastest for n greater than about 30.
     ## Put cutoff elements between boundaries, integrate over all
@@ -107,7 +107,7 @@
     chist = cumsum (idx <= len);
     t1 = zeros (1, columns (y));
     t2 = reshape (chist(idx > len), size (cutoff));
-    t3 = chist(end,:);
+    t3 = chist(end,:) - sum (isnan (y));
     chist = [t1; t2; t3];
   endif
 
@@ -141,6 +141,10 @@
 %!  assert(xx, [1.5,2.5,3.5]);
 %!  assert(nn, [2,1,1]);
 %!test
+%!  [nn,xx]=hist([1 1 1 NaN NaN NaN 2 2 3],[1 2 3]);
+%!  assert(xx, [1,2,3]);
+%!  assert(nn, [3,2,1]);
+%!test
 %!  [nn,xx]=hist([[1:4]',[1:4]'],3);
 %!  assert(xx, [[1.5,2.5,3.5]',[1.5,2.5,3.5]']);
 %!  assert(nn, [[2,1,1]',[2,1,1]']);