I have a 256x4 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?

Help would be really appreciated. I want all the rows as separate matrices. See, I have a 256x4 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.

 Accepted Answer

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

1 Comment

I had to modify this a bit. But thanks for giving me the idea behind it. What I actually wanted was out=mat2cell(m,ones(256,1),4)
Thanks.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!