I have a logical aray, a 370x29 matrix. I am trying to find all 1s and 0s that are non-consecuitve and replace them with the other one, in each column. So in a series: 00000100000 I want to be able to find and replace that stand alone 1 with a 0, and in a series: 1111101111 I want to find and replace that 0 with a 1. So far, I have been able to find and replace these with this script, where a is my 370x29 matrix:
The only problem with this is that it also finds and replaces the first 1 in a string of 1s and the first 0 in a string of 0s.
Is there any way to find and replace these stand alone 1s and 0s?