Reshape a multidimensional matrix

i have a multidimensional matrix (146x146x144) that i want to reshape (144x21316). the command reshape works "vertically", how i can reshape "horizontally" ( every rows next to another)

답변 (2개)

madhan ravi
madhan ravi 2020년 9월 23일
편집: madhan ravi 2020년 9월 23일

0 개 추천

reshape(permute(matrix, [3, 2, 1]), 144, [ ])

댓글 수: 9

elena galvano
elena galvano 2020년 9월 23일
if i check the results like matrix1(1,1,:) and matrix 2(:,1) they are not the same
madhan ravi
madhan ravi 2020년 9월 23일
편집: madhan ravi 2020년 9월 23일
m(:, :, 1) = [1:2;3:4];
m(:, :, 2) = [5:6;7:8];
What should be the result for the above matrix?
elena galvano
elena galvano 2020년 9월 23일
for examplei have a matrix
[ 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3 3]
i want to reshape in this way:
[ 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 ]
not this way
[1 2 3 1 2 3 ....]
madhan ravi
madhan ravi 2020년 9월 23일
Respond to my comment.
elena galvano
elena galvano 2020년 9월 23일
it's not clear
madhan ravi
madhan ravi 2020년 9월 23일
편집: madhan ravi 2020년 9월 23일
Do you know what a 3D matrix is ? The one you showed is not that , in fact I don’t know if it’s 1D, 2D , 3D or MD? When I pasted the example that you gave in MATLAB, it shows an error. Help us to help you.
elena galvano
elena galvano 2020년 9월 23일
i know what it is.. i told you that the first matrix is a multidimensional (146*146*144) and i want to reshape in a (144x21316). i showed to you that matrix to explain how i want to order the cells.
madhan ravi
madhan ravi 2020년 9월 23일
편집: madhan ravi 2020년 9월 23일
reshape(permute(matrix, [2, 1, 3]), 144, []).'
for examplei have a matrix
[ 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3 3]
That has one too many 3's in the last row. Correcting that problem:
A = [ 1 1 1 1 1 1 1 1 1;
2 2 2 2 2 2 2 2 2;
3 3 3 3 3 3 3 3 3];
P = reshape(A.', 1, [])
If your A array is actually a 3-dimensional (or generally N-dimensional for N > 2) you're going to want to use permute instead of the .' operator.
P2 = reshape(permute(A, [2 1]), 1, [])
To ask a similar question that madhan ravi did, for this specific array:
B = reshape(1:24, [2 3 4])
What exactly do you want the result of reshaping B to be? Give us the explicit command to create Breshaped:
Breshaped = [ % Fill in numbers here]
Once we know what you want Breshaped to be we can help you write the command to create it.

댓글을 달려면 로그인하십시오.

KSSV
KSSV 2020년 9월 23일

0 개 추천

iwant = reshape(144,[]) ;
Wont this work for you?

카테고리

도움말 센터File Exchange에서 Encryption / Cryptography에 대해 자세히 알아보기

태그

질문:

2020년 9월 23일

댓글:

2020년 9월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by