I want to extract items from multiple fields of a structure and put them in an array with unique applied.
Say the structure has this format:
A=repmat( struct('field1',[],'field2',[],'field3',[]) ,100,1);
To extract unique field 1 and field2 I can write this:
[a ia iar]=unique([A(:).field1]);
b=[A(:).field2];
b=b(ia);
I would like to write something like this:
[a ia iar]=unique([A(:).field1]);
b=[A(:).field2](ia);
But Matlab (2012a) doesn't seem to allow accessing items in an array at the time of declaration although the array can be passed to a function without a problem. Is there a way to do this?
Thanks,
David