1

I have a very large dataset arranged into multiple structure arrays in MATLAB. The structures look something like this:

Flight1=   

.testpoint = 1
.Mach = 0.8
.Speed = 300
.Cieling = 35000
.Data = [A] % A is an MxN matrix

Similarly there are multiple test points for multiple flights. Is there a way to retrieve the Data of only specified test points? For example I want to look at the Data of ALL the test points whose .Mach = 0.8 or where .testpoint = 2?

I hope I have made it clear enough.

1 Answers1

2

Assuming you have a struct array Flight where Flight( k ) is a struct with the fields you described, then:

sel = [ Flight(:).Mach ] == 0.8; % select all flights with Mach == 0.8
poitEightMach = Flight( sel );   % selecting them into a separate struct array

sel = [Flight(:).testpoint] == 2;
testPoint2 = Flight( sel );   % select all flights with testpoint == 2
Shai
  • 111,146
  • 38
  • 238
  • 371
  • The Structure is in this format: Flight = Flight1: [1x1 struct] Flight2: [1x1 struct] Flight3: [1x1 struct] Flight4: [1x1 struct] When I apply the code you mentioned, MATLAB gives me this error: Reference to non-existent field 'Mach'. Error in fileread (line 57) sel = [ Flight(:).Mach ] == 0.8 – user2091834 Feb 22 '13 at 11:14
  • @user2091834 please see my answer to [that question](http://stackoverflow.com/a/15050234/1714410) – Shai Feb 24 '13 at 09:09
  • For the life of me I couldn't figure why I was having issues accessing multiple structure values, no matter what I tried only the first value would be returned.... Your use of square brackets fixed it all. Thank you. – Scott G Mar 15 '17 at 21:12