‘... what i am confused about is the (i:end-3+i,j:end-3+j) part.’
Here, end is the size of the array in that dimension. See the documentation on end (link) for a full description, specifically:
- The end function also serves as the last index in an indexing expression. In that context, end is the same as size(X,k) when used as part of the kth index into array X. Examples of this use are X(3:end) to select the third through final elements of the array, and X(1,1:2:end-1) to select all even elements of the first row, excluding the last element. When using end to grow an array, as in X(end+1)=5, make sure X exists first.