필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
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 CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by