MATLAB: How to extract from a vector the element which are in odd position? And in even position

exctract element from a vectorodd elementsodd even

I have the vector A=[2 7 19 3 14 65 32 … N] , and I want to create another vector B which have only the element that are in odd position in vector A. In other world i want to create the vector B=[2 19 14 32 …]. The same for the elements in even position.

Best Answer

B = A(1:2:end)
C = A(2:2:end)
Very basic MATLAB usage, such as this kind of indexing, is introduced in the Getting Started tutorials, which are recompended for all beginners: