how to divide matrix into sub matrix

2 Ansichten (letzte 30 Tage)
sina arfaee
sina arfaee am 23 Feb. 2019
Beantwortet: madhan ravi am 23 Feb. 2019
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

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by