MATLAB: Sorting a matrix in percentiles

matrixseparation into matrices

Good afternoon! I need your help as im new in matlab about solving my following issue:
I have a matrix ret [420×500]
I want to separate this matrix in 10 matrices of [420×50] each. Is there any code than can generate 10 different matrices of same size from the matrix ret[420×500]?
I need 10 equally sized matrices (the breakpoints should be the 10th, 20th, 30th,… , 90th percentiles). I.e., 10 matrices from a given matrix ret.
Thank you in advance!!!

Best Answer

Use mat2cell()
M; % 420x500 matrix
M_parts = mat2cell(M, 420, 50*ones(1,10));
M_parts is a cell array. You can access it like this
M_parts{1}; % 1st 420x50 matrix
M_parts{2}; % 2nd 420x50 matrix
..
..
M_parts{10}; % 10th 420x50 matrix