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