MATLAB: How to split a 420×7 matrix into 60 7×7 matrices

matrix manipulation

Can anyone tell me how I split a 420×7 matrix into 60 matrices of 7×7, and separately store them?

Best Answer

DON'T DO IT!!!!!!
Instead, learn how to use three dimensional arrays. Learn how to work with them, how to create them. For example, here, suppose you do this:
A = rand(420,7);
B = permute(reshape(A,[60,7,7]),[2 3 1]);
So now B is a 7x7x60 array. whos A B Name Size Bytes Class Attributes
A 420x7 23520 double
B 7x7x60 23520 double
Access any single one of them trivially using indexing. The 12th such array is just:
B(:,:,12)
ans =
0.13787 0.94192 0.19343 0.26719 0.52698 0.18676 0.40438
0.10789 0.70595 0.5386 0.40496 0.488 0.20716 0.87572
0.2815 0.67227 0.2296 0.083156 0.55196 0.52085 0.84483
0.30366 0.62026 0.61982 0.85577 0.93162 0.38085 0.42548
0.40673 0.9081 0.88007 0.89641 0.091558 0.71747 0.65392
0.51537 0.96387 0.055953 0.098337 0.54801 0.095945 0.47524
0.36003 0.0086477 0.28221 0.97584 0.95221 0.19791 0.85337
Learn to use MATLAB.