ndgrid on matrices without the use of cell arrays
4 ビュー (過去 30 日間)
古いコメントを表示
Hi guys,
I need your help in solving the following problem:
Given a dxn matrix, do the following (preferably without the use of cells):

n is always even and d is also even.
Thanks in advance.
2 件のコメント
James Tursa
2015 年 12 月 23 日
編集済み: James Tursa
2015 年 12 月 23 日
What is the general pattern? E.g., are the rows always split into 1x2 blocks, or are the rows split in half? Is n always even? You need to give us more information.
回答 (1 件)
Andrei Bobrov
2015 年 12 月 23 日
編集済み: Andrei Bobrov
2015 年 12 月 23 日
m = size(A,1); % A - your array
b = reshape(A,m,[],2);
[ii,jj] = ndgrid(1:m);
out2 = [b(jj(:),:,1),b(ii(:),:,2)]
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!