From: Ilkka Pohjalainen on
Let's say that I have a array of structs, where the struct has an element 'elem1' with an vector element.

If I have a row vector elements I can do this:

>> A=repmat(struct('elem1',[]),1,3)

A =

1x3 struct array with fields:
elem1

>> A(1).elem1=[1,5,2];
>> A(2).elem1=[8,8,8];
>> A(3).elem1=[6,9,6,9];
>> [A.elem1]

ans =

1 5 2 8 8 8 6 9 6 9

However if I have a column vector I cannot do the previos:

>> A=repmat(struct('elem1',[]),1,3)

A =

1x3 struct array with fields:
elem1

>> A(1).elem1=[1,5,2]';
>> A(2).elem1=[8,8,8]';
>> A(3).elem1=[6,9,6,9]';
>> [A.elem1]
??? Error using ==> horzcat
CAT arguments dimensions are not consistent.

I know the reason is that the comlunm vectors don't have the same length as I can do this

>> [A(1:2).elem1]

ans =

1 8
5 8
2 8

But what if I want to have this

>> (command I'm searching)

ans =
1
5
2
8
8
8
6
9
6
9

So how could I get this?
From: us on
"Ilkka Pohjalainen" <ip.quant(a)gmail.com> wrote in message <i0q6nm$3ps$1(a)fred.mathworks.com>...
> Let's say that I have a array of structs, where the struct has an element 'elem1' with an vector element.
>
> If I have a row vector elements I can do this:
>
> >> A=repmat(struct('elem1',[]),1,3)
>
> A =
>
> 1x3 struct array with fields:
> elem1
>
> >> A(1).elem1=[1,5,2];
> >> A(2).elem1=[8,8,8];
> >> A(3).elem1=[6,9,6,9];
> >> [A.elem1]
>
> ans =
>
> 1 5 2 8 8 8 6 9 6 9
>
> However if I have a column vector I cannot do the previos:
>
> >> A=repmat(struct('elem1',[]),1,3)
>
> A =
>
> 1x3 struct array with fields:
> elem1
>
> >> A(1).elem1=[1,5,2]';
> >> A(2).elem1=[8,8,8]';
> >> A(3).elem1=[6,9,6,9]';
> >> [A.elem1]
> ??? Error using ==> horzcat
> CAT arguments dimensions are not consistent.
>
> I know the reason is that the comlunm vectors don't have the same length as I can do this
>
> >> [A(1:2).elem1]
>
> ans =
>
> 1 8
> 5 8
> 2 8
>
> But what if I want to have this
>
> >> (command I'm searching)
>
> ans =
> 1
> 5
> 2
> 8
> 8
> 8
> 6
> 9
> 6
> 9
>
> So how could I get this?

one of the solutions

r=cat(1,A.elem1)

us