MATLAB: Filling a internal value of a matrix

fill

Hi I have the following matrix
I=
0 1 0 0
0 0 1 1
0 1 0 0
0 0 1 0
I want the following output:
0 1 0 0
0 1 1 1
0 1 1 0
0 0 1 0
Is there any easy way to do that,easily?
Thanks

Best Answer

This function will help you: FINDSUBMAT. Here is an example:
I=[0 1 0 0
0 0 1 1
0 1 0 0
1 0 0 0
0 0 1 0
1 0 0 0
0 0 1 0];
idx = findsubmat(I,[1 0 1]'); % Available at the above link...
I(idx+1) = 1
I =
0 1 0 0
0 1 1 1
0 1 0 0
1 0 0 0
1 0 1 0
1 0 1 0
0 0 1 0