how to divide matrix into sub matrix

1 view (last 30 days)
Hi
Come to assume that we have a matrix (6*8) and we want to divide it to 12 (1*4) matrix.
How can we do that?
p.s. mat2cell is not useful for our situation!!!
I write below script but the problem is that the output B only show the last 1*4 matrix, I want to show all 12 matrix in output
clear all;
clc;
A=[1 2 3 4 5 6 7 8;
9 10 11 12 13 14 15 16;
17 18 19 20 21 22 23 24;
25 26 27 28 29 30 31 32;
33 34 35 36 37 38 38 40;
41 42 43 44 45 46 47 48];
row=6;
column=8;
for i=1:row
for j=1:4:column
B=A(i,j:j+3)
end
end
Thanks a lot

Accepted Answer

madhan ravi
madhan ravi on 23 Feb 2019
Result=reshape(A',1,4,[])

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!