MATLAB: Access multiple structure fields and put them in a new structure or vector

fieldmultiplestructure

I have a cell structure with below layout. In below example I acces a single field.
dataArray{1,(2)}(1,1)
Is there a way to acces multiple fields and get them into a new structure or a vector without using a for loop?
E.g. dataArray{1,(2:10)}(1,1)
I'm afraid I use the brackets in a wrong way.

Best Answer

No, what you are asking for is not possible. This syntax:
dataArray{1,2:10}
creates a comma-separated list of separate arrays, which cannot be further indexed into using one pair of parentheses as your example shows.
You can use parentheses (as opposed to curly braces) to return that part of the cell array:
sub = dataArray(1,2:10)
You could use that together with cellfun to return the first element of each of those cells:
out = cellfun(@(a)a(1,1),dataArray(1,2:10))