# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1336603498 14400 # Node ID e7c8e31f8e5d7a14c9d446b4fea35de0d701ac4f # Parent 545580e7ebfa2b187931fae550293fd93be67022 hist.m: Add test to check for correct NaN normalising diff -r 545580e7ebfa -r e7c8e31f8e5d scripts/plot/hist.m --- a/scripts/plot/hist.m Wed May 09 16:59:36 2012 -0400 +++ b/scripts/plot/hist.m Wed May 09 18:44:58 2012 -0400 @@ -149,7 +149,7 @@ if (nargin > 2 && ! ischar (varargin{iarg})) ## Normalise the histogram. norm = varargin{iarg++}; - freq = freq / sum(! isnan (y)) * norm; + freq = freq / sum(! isnan (y)) * norm; endif if (nargout > 0) @@ -182,6 +182,10 @@ %! assert (xx, [1,2,3]); %! assert (nn, [3,2,1]); %!test +%! [nn,xx] = hist ([1 1 1 NaN NaN NaN 2 2 3],[1 2 3], 6); +%! 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]); %! assert (nn, [[2,1,1]',[2,1,1]']);