Re: Addressing array of structures as a matrix of values?



On Oct 31, 1:56 pm, neuromath <mathne...@xxxxxxxxx> wrote:
I have an array of structures that looks something like

data =
1xN struct array with fields:
field1
field2
.
.
.
fieldm

where field1, say, is a 1xK vector. I can clearly access each vector
with

data(n).field1

I'd like to put the 'field1' of each structure in a new row of a
matrix, and one way of doing that uses:

matrix = [data.field1];
matrix = reshape(matrix,[],K);

However, I am just wondering if there is a one-step function that
might be able to do this. Thanks.


a(1,1).field=rand(1,10);
a(2,1).field=rand(1,10);
vertcat(a.field)

ans =

Columns 1 through 7

0.8147 0.9058 0.1270 0.9134 0.6324 0.0975 0.2785
0.1576 0.9706 0.9572 0.4854 0.8003 0.1419 0.4218

Columns 8 through 10

0.5469 0.9575 0.9649
0.9157 0.7922 0.9595


Chris

.



Relevant Pages