Split a matrix into smaller pieces - help

1 Ansicht (letzte 30 Tage)
Itachi
Itachi am 10 Sep. 2012
Hi guys, I have a 16x36 matrix and I want to divide it into 4x36 submatrixes. I used reshape(matrix,4,[],4) but the order of elements got wrong. Any ideas?
Best regards,

Akzeptierte Antwort

Matt Fig
Matt Fig am 10 Sep. 2012
Bearbeitet: Matt Fig am 10 Sep. 2012
A = reshape(1:36*16,16,36);
B = mat2cell(A,[4 4 4 4],36);
Now you have each submatrix stored in a cell of B. For example, B{1} is:
B{1}
  3 Kommentare
Matt Fig
Matt Fig am 10 Sep. 2012
Bearbeitet: Matt Fig am 10 Sep. 2012
With A as above:
B = permute(reshape(A.',36,4,4),[2,1,3])
Itachi
Itachi am 10 Sep. 2012
Bearbeitet: Itachi am 11 Sep. 2012
Thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by