MATLAB: I have a 256×4 matrix. I want to divide the matrix into 256 matrices of 4 elements each. I am having a lot of difficulties. I tried using the mat2cell fn but it does not accept variable values. I would have to write ‘1’ 256 times. Any suggestions

matricesmatrix arraymatrix manipulation

Help would be really appreciated. I want all the rows as separate matrices. See, I have a 256×4 matrix which I eventually plan to increase in size. After this matrix generation am planning to operate upon all the rows separately. I actually want to re-shape these division of rows into matrices again and then work on them separately. Any help would be highly appreciated.

Best Answer

M=rand(256,4)
out=mat2cell(M,4*ones(64,1),4)