フィルターのクリア

How to quickly change 3D to 2D Matrix

1 回表示 (過去 30 日間)
Tim
Tim 2013 年 12 月 17 日
コメント済み: Tim 2013 年 12 月 17 日
I've a Matrix e.g.
A(:,:,1) =
1 1 1
2 2 2
3 3 3
A(:,:,2) =
4 4 4
5 5 5
6 6 6
A(:,:,3) =
7 7 7
8 8 8
9 9 9
As a result I want a Matrix "B" that is just 2D in the following shape:
B =
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
I played around with reshape() and permute() or repmat() but couldn't get to the desired result. I solved the problem with a loop but I want to avoid loops!
Thanks!

採用された回答

Andrei Bobrov
Andrei Bobrov 2013 年 12 月 17 日
編集済み: Andrei Bobrov 2013 年 12 月 17 日
B = reshape(permute(A,[2 1 3]),size(A,2),[])';
or
p = num2cell(A,[1 2]);
B = cat(1,p{:});
  1 件のコメント
Tim
Tim 2013 年 12 月 17 日
perfect! Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by