Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个像这样的单元格数组(输入):
A(1,1) = {[1 2]}; A(1,2) = {[4 5 6]};
现在对于 A 的每一行(在这种情况下只有 1 行),我想得到这样的点向量:
A_row1 =[ 1 4; 1 5; 1 6; 2 4; 2 5; 2 6]
我想知道是否有任何方法可以在没有循环的情况下解决这个问题?
怎么样:
[x, y] = ndgrid(A{1}, A{2}) B = [x(:) y(:)]
我认为这应该可以解决问题:
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