Code covered by the BSD License  

Highlights from
Split nD-array into equal sized cells

2.0 | 1 rating Rate this file 21 Downloads (last 30 days) File Size: 1.64 KB File ID: #35085 Version: 1.0

Split nD-array into equal sized cells


Matt J (view profile)


Splits an array of any dimension into cell array of equal sized chunks.

| Watch this File

File Information

MAT2TILES is basically a wrapper for mat2cell but with a more convenient interface when you are simply trying to decompose an N-dimensional array into equal-sized chunks. It takes the desired chunk-size as an input argument, whereas mat2cell does not. MAT2TILES also has some convenient shortcuts for when you only want to tile along particular dimensions (see below).

will produce a cell array C containing adjacent chunks of the array X, with each chunk of dimensions D1xD2xD3x...xDn. If a dimension Di does not divide evenly into size(X,i), then the chunks at the upper boundary of X along dimension i will be truncated.
It is permissible for the Di to be given value Inf. When this is done, it is equivalent to setting Di=size(X,i). This is useful if you want to tile along only certain array dimensions.
If n < ndims(X), then the unspecified dimensions Dj, n<j<=ndims(X) will be
set to size(X,i).
If n > ndims(X), the the extra dimensions Dj, j>ndims(X) will be ignored.

MATLAB release MATLAB 7.13 (R2011b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
03 Jun 2015 Matt J

Matt J (view profile)

As mentioned in the Description section above, the routine is very similar in what it accomplishes to MATLAB's native mat2cell, differing only in its input syntax. Therefore, I didn't foresee the need for examples, which are already available in the mat2cell documentation. The input syntax for mat2tiles, you will find explained in its help comments


As in mat2cell, X is a numeric input array and C is the same array partitioned into cells. The Di are the dimensions of the partitions.

Comment only
02 Jun 2015 Matthew

Interesting function and potentially very useful. However, neither your code nor its comments provide even a basic example that properly demonstrates its usage.

Contact us