MATLAB: Find first value and repalce values following it

findindexing

Good morning, I have an the following matrix 6*3:
1 1 1
1 1 1
0 1 1
1 1 0
1 1 1
0 0 1
I want to keep the first zero of each colomne and to replace the values that follow it by zeros to get:
1 1 1
1 1 1
0 1 1
0 1 0
0 1 0
0 0 0
Thank you for help bests

Best Answer

A = [1 1 1
1 1 1
0 1 1
1 1 0
1 1 1
0 0 1];
cumprod(A)
Related Question