Split a specific matrix in 4 equal parts

8 Ansichten (letzte 30 Tage)
Daniele Cuomo
Daniele Cuomo am 19 Jun. 2020
Bearbeitet: KSSV am 19 Jun. 2020
If I define the matrix as follows:
Given 4 matrix of equal dimensions, say A, B, C, D.
Let
E = [A B; C D];
May I do something like (totally pseudo-code):
B2 = E(B);
to retrieve the submatrix B without the use of cell arrays?

Akzeptierte Antwort

KSSV
KSSV am 19 Jun. 2020
Bearbeitet: KSSV am 19 Jun. 2020
M = rand(8) ;
[m,n] =size(M) ;
A = M(1:n/2,1:n/2) ;
B = M(1:n/2,n/2+1:end) ;
C = M(n/2+1:end,1:n/2) ;
D = M(n/2+1:end,n/2+1:end) ;
But the best would be:
m =size(M,1)/2 ;
A = mat2cell(M,[m m],[m m]) ;
A{1,1}
A{1,2}
A{2,1}
A{2,2}

Weitere Antworten (0)

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by