MATLAB: Store all array values in a field to a variable

struct

I have a test.mat file which contains 1×10 struct array values with 5 fields. The first field 'f' ie,. 'test.f' contains struct array with a dimension of [2×1 double]. I wanted to store all these 10 [2×1 double] values to another variable 'f_vec'. I tried 'getfield'
f_vec = getfield(test,'f')
but it gives out only 1 [2×1 double] value and not all the values from the struct array. when I tried the below command, I got an error.
f_vec = test.f(1,:)
??? Field reference for multiple structure elements that is followed by more
reference blocks is an error.
So all I wanted to do is to store all the [2×1 double] values from 'f' to f_vec. How do I do it ? Thank you.

Best Answer

f_vec = horzcat( test.f ); %would give you 2 x length(test) array