Hello. I have a matrix with '0' and '1', of variable size. For example:
A = 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 1 0 0 0 0 1 1
My goal is to create B where every '1' is changed to '0', except for every nth '1' (let's assume 3rd, for this example). The code should sweep row by row, searching from left to right.
B = 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
Thank you.
Best Answer