I have a matrix of size 64500x17
. It represents detected texton features that I have to use to find 5 centroids for kmeans
.
What I need is:
12900x17
matrices5x17
matrix to feed in to the start parameter of kmeans
.I know how to do almost everything (cat
, kmeans
, etc), but I am merely trying to find a method for splitting the matrix into 5 parts, or summing/dividing into the desired size.
I am forbidden from overusing for loops (due to efficiency), unless absolutely necessary.
I can't find any pertinent example in other questions, so if this has been answered, please bear with me.
You can use mat2cell
and this oneliner
C = mat2cell(A, repmat(12900, 5, 1), 17);
The second parameter to mat2cell
is the row split of the matrix.
Now C
is a cell array:
C =
[12900x17 double]
[12900x17 double]
[12900x17 double]
[12900x17 double]
[12900x17 double]
and the partial matrices can be accessed as
C{1} etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With