I have a vector like this:
or it could also be like this:
- 153 158 161 163 172 123 179 181
if I look at the vector, I know I should delete 100 in 1st one and 123 in 2nd one. After that, either vector is in an increasing order.
I tried to use code diff(vector) to solve the problem in Matlab.
For 1st vector, the difference: 1 1 1 96 -95 1 1. The negative appears at 5th and I should delete No.5 in original sample.
For 2nd vector, the difference: 5 3 2 9 -49 56 2. The negative appears at 5th but I should delete No.6 in original sample.
The code diff cannot handle both cases at the same time. I am wondering if there is a more effective way.
Thank you very much!