MATLAB: Access value in cell arrays

cell arrays

A{1,1}.str = 1;
A{2,1}.str = 2;
... (so on)
A{10,1}.str = 10;
Can I say:
B = A{:,1}.str;
so that:
B=[1 2 3 4 5 6 7 8 9 10];
Thanks very much

Best Answer

What you look for can be achieved with cellfun, see below.
Indexing like C{:}.field is not supported (AFAIK).
The script
S1.field=1;
S2.field=2;
S3.field=3;
C = { S1, S2, S3 };
C{1}.field
C{2}.field
C{3}.field
C{:}.field
returns
ans =
1
ans =
2
ans =
3
Bad cell reference operation.
And
vec = cellfun( @(S) S.field, C, 'uni', true )
returns
ans =
1 2 3
.
EDIT
The single command with cellfun is justified in case the cells of the cell array contain structures with only some fields in common.
Example:
S1.field=1;
S2.field=2;
S3.field=3;
S1.field1=1;
S2.field2=2;
S3.field3=3;
C = { S1, S2, S3 };
vec = cellfun( @(S) S.field, C, 'uni', true )
returns
vec =
1 2 3