Reputation: 109
I have an cell Array (input) like this:
A(1,1) = {[1 2]}; A(1,2) = {[4 5 6]};
now for each row of A (in this case only 1) I would like to obtian the vector of points like this:
A_row1 =[ 1 4; 1 5; 1 6; 2 4; 2 5; 2 6]
I wonder if there is any method to cope with this without a loop?
Upvotes: 2
Views: 120
Reputation: 14939
I think this should do the trick:
B = sortrows([repmat(A{1}',size(A{2},2),1) repmat(A{2}',size(A{1},2),1)])
B =
1 4
1 5
1 6
2 4
2 5
2 6
Upvotes: 1