I need effectively eliminate (by zeroing) the consecutive "1's" between "-1's" and start/end of column at each column of matrix A, which now can be separated by any number of zeroes. The number of consecutive "1's" between "-1's" and start/end of column is > N. This is a non-trivial generalization of my previous Question.
Again, typical size(A) = [100000,1000].
See example:
A = 1 -1 0 0 1 1 0 1 1 1 1 0 0 0 1 1 -1 0 -1 1 1 -1 0 -1 1 1 1 0 1 -1
For N = 2 the expected result is
Aclean = 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 -1 0 -1 1 0 1 0 0 -1
For N = 3 the expected result is
Aclean = 1 -1 0 0 1 0 0 1 0 1 1 0 0 0 0 1 -1 0 -1 1 0 -1 0 -1 1 1 1 0 1 -1
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
4 Comments
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/421655-elimination-of-conscutive-regions-generalization-ones-with-zeros-between#comment_616580
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/421655-elimination-of-conscutive-regions-generalization-ones-with-zeros-between#comment_616580
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/421655-elimination-of-conscutive-regions-generalization-ones-with-zeros-between#comment_616590
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/421655-elimination-of-conscutive-regions-generalization-ones-with-zeros-between#comment_616590
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/421655-elimination-of-conscutive-regions-generalization-ones-with-zeros-between#comment_616593
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/421655-elimination-of-conscutive-regions-generalization-ones-with-zeros-between#comment_616593
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/421655-elimination-of-conscutive-regions-generalization-ones-with-zeros-between#comment_616596
Direct link to this comment
https://ww2.mathworks.cn/matlabcentral/answers/421655-elimination-of-conscutive-regions-generalization-ones-with-zeros-between#comment_616596
Sign in to comment.