How to split a 3d matrix into sub-3d matrices?

How can I split e.g. a 100x100x100 matrix into non-overlapping (neighbouring) smaller matrices 10x10x10? or how to use mat2cell for this problem?

 採用された回答

Stephen23
Stephen23 2016 年 9 月 21 日
編集済み: Stephen23 2016 年 9 月 21 日

2 投票

It is easy to split that array using mat2cell, you just need to define a vector that defines how to split each of the dimensions:
A = rand(100,100,100);
D = 10*ones(1,10);
C = mat2cell(A,D,D,D);
and the output:
>> size(C)
ans =
10 10 10
>> size(C{1})
ans =
10 10 10

その他の回答 (1 件)

Matt J
Matt J 2017 年 12 月 28 日
編集済み: Matt J 2017 年 12 月 28 日

0 投票

For an easier interface, you can instead use mat2tiles (Download), e.g.,
>> C = mat2tiles( rand(100,100,100), [10,10,10]);
>> whos C
Name Size Kilobytes Class Attributes
C 10x10x10 7922 cell

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

ML
2016 年 9 月 20 日

編集済み:

2017 年 12 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by