MATLAB: Delete element from a vector within a given range

aa

Hi everyone,
Assuming I have a Vector say A = [2 3 1 8 1 8 4 1 3 6 7 5 6 8 1], and I want to delete the first 7 elements that are less than two. Therefore having A = [2 3 8 8 4 1 3 6 7 5 6 8 1]. Can someone please explain to me how to do this in Matlab?
Thanks

Best Answer

"I want to delete the first 7 elements that are less than two"
A( find(A < 2, 7, 'first') ) = [];
You only have four elements that are less than 2, so it will delete all four of them.
I think you used the wrong wording and that what you want is
A( A(1:7) < 2 ) = [];