Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
8611:1e47b5f04b4c | 8612:20d23d65cc84 |
---|---|
91 args = cell (1, 2 * numel (names)); | 91 args = cell (1, 2 * numel (names)); |
92 args(1:2:end) = names; | 92 args(1:2:end) = names; |
93 args(2:2:end) = {[]}; | 93 args(2:2:end) = {[]}; |
94 t = struct (args{:}); | 94 t = struct (args{:}); |
95 else | 95 else |
96 n = numel (s1); | |
96 for i = 1:numel (names) | 97 for i = 1:numel (names) |
97 el = names(i); | 98 el = names(i); |
98 for k = 1:length (s1) | 99 [t(1:n).(el)] = s1(:).(el); |
99 t(k).(el) = s1(k).(el); | |
100 endfor | |
101 endfor | 100 endfor |
101 ## inherit dimensions | |
102 t = reshape (t, size (s1)); | |
102 endif | 103 endif |
103 | 104 |
104 endfunction | 105 endfunction |
105 | 106 |
106 %!shared a, b, c | 107 %!shared a, b, c |