Here are a few methods to try:
>> A = [0,0,0,0,1,0;0,0,0,1,0,0;1,0,0,0,0,1;0,0,1,1,1,1;0,1,0,1,1,0]
A =
0 0 0 0 1 0
0 0 0 1 0 0
1 0 0 0 0 1
0 0 1 1 1 1
0 1 0 1 1 0
>> B = +(cumsum(A,1)>0)
B =
0 0 0 0 1 0
0 0 0 1 1 0
1 0 0 1 1 1
1 0 1 1 1 1
1 1 1 1 1 1
>> B = sign(cumsum(A,1))
B =
0 0 0 0 1 0
0 0 0 1 1 0
1 0 0 1 1 1
1 0 1 1 1 1
1 1 1 1 1 1
>> B = +~~cumsum(A,1)
B =
0 0 0 0 1 0
0 0 0 1 1 0
1 0 0 1 1 1
1 0 1 1 1 1
1 1 1 1 1 1
Best Answer