MATLAB: How to replace 2×2 zero sub matrices by different 2×2 matrices

arraysmatricesmatrixmatrix array

How to replace 2×2 zero submatrix of B with 2×2 matrices different matrice.I have 12 matrices of size 2×2 and want to replace zeros of B by those matrices.
B =
0.8776 0.6513 0 0 0 0 0 0
0.0144 0.8646 0 0 0 0 0 0
0 0 0.2943 0.0560 0 0 0 0
0 0 0.1799 0.8169 0 0 0 0
0 0 0 0 0.9263 0.5289 0 0
0 0 0 0 0.0682 0.6944 0 0
0 0 0 0 0 0 0.5811 0.2124
0 0 0 0 0 0 0.6372 0.5433
Thanks

Best Answer

basically i want solution in this form
x p1 p2 p3
p1 x p2 p3
p1 p2 x p3
p1 p2 p3 x
C={zeros(2), p1,p2,p3};
result=B+cell2mat( C(toeplitz(1:4)) );