To split a matrix into equal parts.
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi, I am hanging with a problem regarding matrix splitting. I have a 128 by 128 matrix and want to split it into 16 equal matrices(i.e. having dim 32 by 32). Now, want to extract the middle element from each of these newly derived matrices(i.e from 32 by 32 one)to construct a new matrix having only 16 elements(i.e. 4 by 4 matrix).Since 32 by 32 is an even dim matrix so extraction from next to the middle one is required. Can anyone please help me out in doing this? Thanking you!
댓글 수: 0
채택된 답변
Friedrich
2012년 1월 4일
Hi,
why reshaping? When you know which elements you like, use linear indexing. This example pics up the elemtents (16,16), (48,16) and so on
a = rand(128);
a(16:32:128,16:32:128)
댓글 수: 0
추가 답변 (1개)
Titus Edelhofer
2012년 1월 4일
Hi,
depends if you need the intermediate 16 matrices or only the 16x16 matrix. The latter would be simply
A = rand(128,128);
A16 = A(17:32:end, 17:32:end);
% or "the other middle"
A16 = A(16:32:end, 16:32:end);
Titus
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!