# HG changeset patch # User Rik # Date 1400876720 25200 # Node ID 9040ad7feb354584c182f9a30b65597b2a2170c2 # Parent d99475e26c787f2e41a2b458bf79a4d715399ecd Fix regression in hist with multiple columns and normalization (bug #42394). * hist.m: Use bsxfun to expand out normalization constant from scalar to vector if necessary. Add %!tests for correct behavior. diff -r d99475e26c78 -r 9040ad7feb35 scripts/plot/draw/hist.m --- a/scripts/plot/draw/hist.m Fri May 23 13:04:57 2014 -0700 +++ b/scripts/plot/draw/hist.m Fri May 23 13:25:20 2014 -0700 @@ -157,7 +157,7 @@ if (nargin > 2 && ! ischar (varargin{iarg})) ## Normalize the histogram. norm = varargin{iarg++}; - freq *= norm / sum (! isnan (y)); + freq = bsxfun (@times, freq, norm ./ sum (! isnan (y))); endif if (nargout > 0) @@ -209,4 +209,6 @@ %! endfor %!assert (hist (1,1), 1) %!assert (size (hist (randn (750,240), 200)), [200,240]) - +## Test bug #42394 +%!assert (isempty (hist (rand (10,2), 0:5, 1)), false) +%!assert (isempty (hist (rand (10,2), 0:5, [1 1])), false)