erasing particular rows of a vector
1 view (last 30 days)
and I want to erase the rows that contain zero and the element that follows immediately after zero
So I want to erase the elements [0,2], [0,12] and [0,23]
Note that zeros can appear anywhere in the vector. The above vector is a simple example
More Answers (1)
Albert Yam on 1 Aug 2012
Look for the index of the elements that are zero. That is to say 'find' them. Once you have them, you know that those index '+1', are the rows that follow. Then remove them (all at once, or backwards).