Hi all,
I have a question concerning reshaping a 2D array into a 3D array, where each 2D array is arranged by a block of rows and columns from the original.
Say I have an array 'aa'
'aa' is comprised of a number of blocks of data = x, with a number of rows = n, and number of columns = m
For example if
x = 2
n = 2
m = 3
aa = randi(1000,x*n,m);
Can anyone show me how to reshape 'aa' into a destination array 'bb' to be organized as follows
bb(:,:,1) = aa(1:n,:);
bb(:,:,2) = aa(n+1:2*n,:);
The same pattern repeats for the full size of my problem (x = 30 , n = 440, m =320)
I am trying to avoid loops as the number of blocks of data 'x' is likely to increase down the road.
Thank you in advance for any help that you may provide.
Chris

댓글 수: 2

madhan ravi
madhan ravi 2020년 7월 14일
Why did you edit after I answered??
Christopher
Christopher 2020년 7월 14일
I was trying to make my question more clear and I didn't see your answer when I was editing it. I accepted it as correct, thanks again and sorry for the confusion on my part.

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

 채택된 답변

madhan ravi
madhan ravi 2020년 7월 14일

0 개 추천

bb = reshape(aa.', 1, [], size(aa,2))

댓글 수: 1

Christopher
Christopher 2020년 7월 14일
This is exactly what I was looking for, thank you very much.

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2020a

질문:

2020년 7월 14일

댓글:

2020년 7월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by