splitting a matlab matrix into several equal parts

后端 未结 4 1433
死守一世寂寞
死守一世寂寞 2021-01-12 09:22

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:

4条回答
  •  一个人的身影
    2021-01-12 09:38

    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.
    

提交回复
热议问题