Post by Bruce Bowler Post by dpb
Sure, that's no problem at all...since the two directory structures will
have same fields, just concatenate and sort the result...in explicit
form it would look like
then process the combined directory structure d in the sequence returned.
Which is, essentially, what I suggested...
The method I got from support was to turn it into a table, sort the table,
and then turn it back into a structure...
d1 = dir('*.m');
d2 = dir('*.txt');
d = [d1;d2];
d = table2struct(sortrows(struct2table(d),'datenum'));
Which is more overhead than the "dead ahead" solution I'd venture by a
measurable mount owing to the cast to/from the struct. You still have
SORT and then to iterate over the struct anyway, so what's the
difference in using the index vis a vis the loop variable?
If I were doing this I'd just cut out the intermediary step and write