Finding all pairs of non overlapping n/2*n/2 submatrices in an n*n matrix.

3 次查看(过去 30 天)
Hi guys, I have seen this question here: http://uk.mathworks.com/matlabcentral/answers/169278-all-submatrices-of-given-order-of-a-given-matrix but I would like to be able to find all pairs of n/2*n/2 non overlapping submatrices in a given n*n matrix. Any ideas would be much appreciated.
EDIT: Note that here if one submatrix contains rows and columns 1 and 2, its pair must contain only rows and columns 3 and 4.
Many thanks,
Daniel

回答(1 个)

Harsha Medikonda
Harsha Medikonda 2015-8-19
I understand that you wish to retrieve all pairs of non-overlapping sub-matrices from a matrix. Refer to the following example.
>>m = 4; n = 4;
>>mx = reshape(1:m*n, m, n);
>>rearranged=im2col(mx,[2 2],'sliding')
>>count_submatrices = size(rearranged,2)
>>s = reshape(rearranged, [2 2 count_submatrices])
In the above code we are creating a 4*4 matrix, and finding the non-overlapping 2*2 sub-matrices using "im2col" function.
Refer to the following documentation pages for more information

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by