I have got an N×M matrix m
like:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
I want to get all submatrices of size P×Q (P,Q are odd) w/o employing a for-loop.
The result s
should be a P×Q×((N-P+1)·(M-Q+1)) matrix.
E.g. if P=Q=3:
s(:,:,1) = [1 2 3; 5 6 7; 9 10 11]
s(:,:,2) = [2 3 4; 6 7 8; 10 11 12]
s(:,:,3) = [5 6 7; 9 10 11; 13 14 15]
s(:,:,4) = [6 7 8; 10 11 12; 14 15 16]
5 6 7
appears twice. – Additional