Filter löschen
Filter löschen

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

4 Ansichten (letzte 30 Tage)
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 .

Akzeptierte Antwort

Torsten
Torsten am 9 Apr. 2022
A = reshape(A(:),6,3)

Weitere Antworten (1)

Voss
Voss am 9 Apr. 2022
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

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by