MATLAB: Copy of one field of a structured array

arraystructures

Is there a way to make a copy of one field of a structured array without doing a loop? I have tried but it just results in the first element.
Creation of sample structure
for i=1:5
A(i).A = i;
A(i).B = i+10;
end
>>C = A.B
C =
11
Likewise
>> C = A(1:3).B
C =
11
instead of C(1).B = 11, C(2).B = 12, and C(3).B = 13 like I want.

Best Answer

One way to do it:
>> C = cell2struct( num2cell([A.B]), {'B'} )
C =
5x1 struct array with fields:
B
>> C(1).B
ans =
11
>> C(2).B
ans =
12
another
>> C = struct( 'B', num2cell([A.B]) )
C =
1x5 struct array with fields:
B
>> C(1).B
ans =
11
>> C(2).B
ans =
12
>>