Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
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 .

Réponse acceptée

Torsten
Torsten le 9 Avr 2022
A = reshape(A(:),6,3)

Plus de réponses (1)

Voss
Voss le 9 Avr 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

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by