diff scripts/general/sub2ind.m @ 4911:14027e0bafa4

[project @ 2004-07-22 19:58:06 by jwe]
author jwe
date Thu, 22 Jul 2004 19:58:06 +0000
parents c0302db81b75
children c08cb1098afc
line wrap: on
line diff
--- a/scripts/general/sub2ind.m
+++ b/scripts/general/sub2ind.m
@@ -46,9 +46,9 @@
 	      error ("sub2ind: index out of range");
 	    endif
 	  else
-	    if (all (size (first_arg) == size (arg)))
+            if (prod (size (first_arg)) == prod (size (arg)))
 	      if ((i > nd && arg == 1) || (arg > 0 & arg <= dims(i)))
-		ind += scale(i-1) * (arg - 1);
+		ind(:) += scale(i-1) * (arg(:) - 1);
 	      else
 		error ("sub2ind: index out of range");
 	      endif