Split a specific matrix in 4 equal parts

16 次查看(过去 30 天)
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?

采纳的回答

KSSV
KSSV 2020-6-19
编辑:KSSV 2020-6-19
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}

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by