diff scripts/general/accumarray.m @ 9859:5919f2bd9a99

small improvements in accumarray
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 24 Nov 2009 12:59:09 +0100
parents 9cb0c21e97f7
children 9a16a61ed43d
line wrap: on
line diff
--- a/scripts/general/accumarray.m
+++ b/scripts/general/accumarray.m
@@ -105,7 +105,7 @@
         endif
 
         ## Convert multidimensional subscripts.
-        subs = sub2ind (sz, mat2cell (subs, rows (subs), ones (1, ndims)){:});
+        subs = sub2ind (sz, num2cell (subs, 1){:});
       elseif (nargin < 3)
         ## In case of linear indexing, the fast built-in accumulator
         ## will determine the extent for us.
@@ -145,7 +145,7 @@
   [subs, idx] = sortrows (subs);
 
   if (isscalar (val))
-    val = val * ones (size (idx));
+    val = repmat (size (idx));
   else
     val = val(idx);
   endif