diff scripts/general/repmat.m @ 4945:4bd917f8a4a7

[project @ 2004-08-31 15:09:17 by jwe]
author jwe
date Tue, 31 Aug 2004 15:09:17 +0000
parents 9f7ef92b50b0
children 269c3d6c0569
line wrap: on
line diff
--- a/scripts/general/repmat.m
+++ b/scripts/general/repmat.m
@@ -55,13 +55,17 @@
     if (isstr (a))
       x = setstr (toascii (a) * ones (idx));
     else
-      x = a * ones(idx);
+      x = a * ones(idx, class(a));
     endif
   elseif (ndims (a) == 2 && length (idx) < 3)
     if (isstr (a))
       x = setstr (kron (ones (idx), toascii (a)));
+    elseif (strcmp (class(a), "double")) 
+      x = kron (ones (idx), a);
     else
-      x = kron (ones (idx), a);
+      aidx = size(a);
+      x = a (kron (ones (1, idx(1)), 1:aidx(1)),  
+	     kron (ones (1, idx(2)), 1:aidx(2)));
     endif
   else
     aidx = size(a);
@@ -70,7 +74,7 @@
     elseif (length(aidx) < length(idx))
       aidx = [aidx, ones(1,length(idx)-length(aidx))];
     endif
-    cidx = cell ();
+    cidx = cell (1, length (aidx));
     for i=1:length(aidx)
       cidx{i} = kron (ones (1, idx(i)), 1:aidx(i));
     endfor