diff scripts/miscellaneous/orderfields.m @ 8612:20d23d65cc84

fix & optimize orderfields
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 28 Jan 2009 07:23:35 +0100
parents 9fc72c114ce1
children eb63fbe60fab
line wrap: on
line diff
--- a/scripts/miscellaneous/orderfields.m	Tue Jan 27 23:48:57 2009 -0500
+++ b/scripts/miscellaneous/orderfields.m	Wed Jan 28 07:23:35 2009 +0100
@@ -93,12 +93,13 @@
     args(2:2:end) = {[]};
     t = struct (args{:});
   else
+    n = numel (s1);
     for i = 1:numel (names)
       el = names(i);
-      for k = 1:length (s1)
-	t(k).(el) = s1(k).(el);
-      endfor
+      [t(1:n).(el)] = s1(:).(el);
     endfor
+    ## inherit dimensions
+    t = reshape (t, size (s1));
   endif
 
 endfunction