# HG changeset patch # User Jaroslav Hajek # Date 1233123815 -3600 # Node ID 20d23d65cc8414fb9443db8d72f180add8b1c066 # Parent 1e47b5f04b4c38f682d34cefa8d8682190fe700d fix & optimize orderfields diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2009-01-28 Jaroslav Hajek + + * miscellaneous/ordefields.m: Use indexed assignment instead of a + loop. Fix for multidimensional cases. + 2009-01-27 John W. Eaton * general/arrayfun.m, image/imwrite.m, plot/axis.m, plot/clf.m, diff --git a/scripts/miscellaneous/orderfields.m b/scripts/miscellaneous/orderfields.m --- a/scripts/miscellaneous/orderfields.m +++ b/scripts/miscellaneous/orderfields.m @@ -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