Combine all columns of each slice in array as one column then convert it to 2D matrix

1 回表示 (過去 30 日間)
M
M 2022 年 4 月 9 日
コメント済み: M 2022 年 4 月 9 日
There is 3D matrix with size (2*3*128) , How to Combine all columns of each slice as one column then convert it to 2D matrix.
For example: This is part from the 3D matrix :
val(:,:,1) =
-0.1031 -0.1163 0.1386
-0.9947 -0.9932 0.9903
val(:,:,2) =
-0.1030 -0.1127 0.1255
-0.9947 -0.9936 0.9921
val(:,:,3) =
-0.1031 -0.1162 0.1452
-0.9947 -0.9932 0.9894
How to combine the columns as the following:
-0.1031
-0.9947
-0.1163
-0.9932
0.1386
0.9903
and do that for each slice
Then convert it to 2D matrix ,, the matrix contains all the columns .

採用された回答

Torsten
Torsten 2022 年 4 月 9 日
A = reshape(A(:),6,3)

その他の回答 (1 件)

Voss
Voss 2022 年 4 月 9 日
val(:,:,1) = [
-0.1031 -0.1163 0.1386
-0.9947 -0.9932 0.9903];
val(:,:,2) = [
-0.1030 -0.1127 0.1255
-0.9947 -0.9936 0.9921];
val(:,:,3) = [
-0.1031 -0.1162 0.1452
-0.9947 -0.9932 0.9894];
result = reshape(val,[],size(val,3))
result = 6×3
-0.1031 -0.1030 -0.1031 -0.9947 -0.9947 -0.9947 -0.1163 -0.1127 -0.1162 -0.9932 -0.9936 -0.9932 0.1386 0.1255 0.1452 0.9903 0.9921 0.9894

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by