# How to make a m*2 matrix into n number of 2x2 matrices

1 view (last 30 days)
Dyl on 7 Sep 2022
Commented: Stephen23 on 8 Sep 2022
Hey,
I have, A = 208x2 matrix. I wish to to spit this matrix into 104 2x2 matrices. I have tried using num2cell and mat2cell but have had no luck. Any help would be appreicated.
Thanks.
Dyl on 7 Sep 2022
Thanks for the replies!

Stephen23 on 7 Sep 2022
A = rand(208,2);
C = mat2cell(A,2*ones(104,1),2)
C = 104×1 cell array
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
Stephen23 on 8 Sep 2022
M = reshape(M,8,13).'

KSSV on 7 Sep 2022
A = rand(208,2) ;
[r,c] = size(A);
nlay = 104 ;
out = permute(reshape(A',[c,r/nlay,nlay]),[2,1,3]);

Abderrahim. B on 7 Sep 2022
Split A
A = randi(10, 208, 2) ; % a mtarix of size 208x2
size(A)
ans = 1×2
208 2
B = reshape(A, 2, 2, []) ;
Access 2x2 matrices
B1 = B(:,:,1)
B1 = 2×2
5 7 9 6
B2 = B(:,:,2)
B2 = 2×2
8 8 4 1
Hope this helps
##### 2 CommentsShow 1 older commentHide 1 older comment
Abderrahim. B on 7 Sep 2022
Thanks @Stephen23. But he does not mention that the order must be te same as in the original matrix!