How to split a 3d matrix into sub-3d matrices?
이전 댓글 표시
How can I split e.g. a a1xb1xc matrix into non-overlapping (neighbouring) smaller matrices a2xb2xc?
답변 (2개)
Bruno Luong
2020년 8월 3일
probably you can use
mat2cell
IMO splitting a matrix in cell is rarely a good idea if you want your code works decenly in speed.
Constantino Carlos Reyes-Aldasoro
2020년 8월 3일
There is not enough information to be certain about your question, but by addressing your matrices you can create submatrices like this:
BigMatrix = ones(16,16,16);
smallMatrix_1 = BigMatrix(1:8,1:8,1:8);
smallMatrix_2 = BigMatrix(1:8,1:8,9:16);
smallMatrix_3 = BigMatrix(1:8,9:16,1:8);
smallMatrix_4 = BigMatrix(9:16,1:8,1:8);
etc.
댓글 수: 6
madhan ravi
2020년 8월 3일
편집: madhan ravi
2020년 8월 3일
What if the numel(matrix) is 16e3 ?
Constantino Carlos Reyes-Aldasoro
2020년 8월 3일
Ok that is big, but rather that numel try using size:
[rows,columns,levels]= size(BigMatrix);
Then you know the size of each dimension. You can then iterate over each by partitioning them, e.g.
subrows = linspace (1,rows,numSections);
subcolumns = linspace (1,columns,numSections);
sublevels = linspace (1,levels,numSections);
so that you then iterate over each section of the rows, columns and levels.
Hope this helps
madhan ravi
2020년 8월 3일
편집: madhan ravi
2020년 8월 3일
Ok, thanks;)
Constantino Carlos Reyes-Aldasoro
2020년 8월 3일
Glad to help! If this solves the question, could you please accept the answer?
madhan ravi
2020년 8월 3일
I’m not the original poster, sorry :(
Constantino Carlos Reyes-Aldasoro
2020년 8월 3일
of course!
카테고리
도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!