One liner solution
Equivalent to [a(:).X(5)] , you can use subsref() to execute [aX](5,:) :
subsref([aX], substruct('()',{5,':'}))
Similarly, a(1)(a(1).Time == 5) can be performed using [a(1).X a(1).Y a(1).Time](a(1).Time == 5,:) :
subsref(cell2mat(struct2cell(a(1))'), substruct('()',{a(1).Time == 5,':'})) ans = 0.6324 0.8003 5.0000
Best approach
I assume that each timestamp has a pair of coordinates, which means that you can save your structure as:
data = [a(1).X a(1).Y a(1).Time];
This will make indexing easier:
data(:,5) data(data(:,3)==5,:)
You can store different sets of coordinates in an array of cells:
data = {[a(1).X a(1).Y a(1).Time] [a(2).X a(2).Y a(2).Time] ...}; data{1}(:,5) data{1}(data{1}(:,3)==5,:)
Oleg source share