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

2 visualizaciones (últimos 30 días)
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 .

Respuesta aceptada

Torsten
Torsten el 9 de Abr. de 2022
A = reshape(A(:),6,3)

Más respuestas (1)

Voss
Voss el 9 de Abr. de 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

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by