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

1 回表示 (過去 30 日間)
Daniel Wilson-NUnn
Daniel Wilson-NUnn 2015 年 8 月 17 日
回答済み: Harsha Medikonda 2015 年 8 月 19 日
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 Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by