Suppose I'm given a struct of arrays, e.g.:
s =
foo: [3x3 double]
bar: [3x1 double]
Is there an easy way to extract a struct with the same field names as s and with each field populated by the ixth row of the same field in s? I can assume that every field has the same number of rows. Given the above, I could do
ix = 1;
s1.foo = s.foo(ix, :);
s1.bar = s.bar(ix, :);
But if s has more than a couple fields, this gets unwieldy. Is there a function that would do the equivalent, a la s1 = extractstruct(s, ix)?
fieldfunstructfun