MATLAB: Selcting elements of a vector with index NOT in a specified index vector

find elements not having a specified indexMATLABvector

Hi,
This maybe a basic question but I am not abe to find an answer by googling. I have a vector , say A = [ 10 20 30 40 50 60 70] and another vector I = [1 3 5 7]. How do I elegantly find the elements of A whose indices do not match the elements of I? Thus, in this case I would like the answer to be [ 20 40 60].
Thanks a lot!

Best Answer

A(setdiff(1:numel(A),index))