MATLAB: Convert a 2×1 structure to 1×1 structure

matrix arraystructures

I received a large data set that I'm trying to work with as part of my dissertation but its in a 2×1 structure (see attached image). Is it possible to convert this to a 1×1 structure or to split them into two 1×1 structures. If not any ideas how I would work with it? How would I change the below code to read in the first structure?
XComp=data.XComp;
YComp=data.YComp;

Best Answer

structures arrays work the same as normal arrays. Just use indexing to access individual elements:
s = struct('f1', {5; 6}, 'f2', {'aaa'; 'bbb'}) %demo data, create a 2x1 struct array
s1 = s(1)
s2 = s(2)