How to reshape the three dimensional array in 2D matrix?

2 ビュー (過去 30 日間)
Sushil Pokharel
Sushil Pokharel 2022 年 7 月 19 日
回答済み: Bruno Luong 2022 年 7 月 19 日
Hi there, I want to reshape the 3D array into 2D matrix form:
for example: I have a matrix,
val(: ,: ,1) =
8 2
3 9
val(: ,: ,2) =
7 6
1 5
Now, I want to reshape this 3D array in the form of 2D matrix.
say A = [ 8 7
2 6
3 1
9 5 ]
Your help will be greatly appreciated.
Thank you.

採用された回答

Bruno Luong
Bruno Luong 2022 年 7 月 19 日
A = reshape(pagetranspose(val),[],size(val,3))

その他の回答 (1 件)

Stephen23
Stephen23 2022 年 7 月 19 日
format compact
A = cat(3,[8,2;3,9],[7,6;1,5])
A =
A(:,:,1) = 8 2 3 9 A(:,:,2) = 7 6 1 5
M = reshape(permute(A,[2,1,3]),4,2)
M = 4×2
8 7 2 6 3 1 9 5

カテゴリ

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

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by