julia> a
4×4 Matrix{Int64}:
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
julia> for i in 1:3
window = CartesianIndices((i:i+1, i:i+1))
a[window] .+= i
end;
julia> a
4×4 Matrix{Int64}:
1 1 0 0
1 3 2 0
0 2 5 3
0 0 3 3
you have a typo, the 4 should be 5 because 2+3 right?