MATLAB: How to index nth item to appear within nested struct

indexingstruct

Is there a way that I can pull out the 'x470A' and 'x405A' from within this struct to create string variables with these names (assuming I hypothetically don't know the names, but want the first and second items under data.streams?)
Essentially I would like to create two new variables, x = 'x470A' and y = 'x405A' and would like to automate it rather than having to print this every time. Thank you in advance!
>> data.streams
ans =
struct with fields:
x470A: [1×1 struct]
x405A: [1×1 struct]
Fi1r: [1×1 struct]
>>

Best Answer

fields = fieldnames(data.streams);%will contain all the fieldnames in a cell array.
x=fields{1};
y=fields{2};
Related Question