I don’t know how to put it in words, but I can with an example. I have the following variable
anglesp = np.linspace(0, 2*np.pi,50)
but I want to extract to a new variable the values at the position 0,2,4,…,50 and so on. Something like this:
angles = anglesp[0,2,4,6...]
>Solution :
numpy arrays can take an iterable (of integers) as an index instead of a single position index. In this case, the [] operation will return a new array containing the items at the specified positions within the iterable.
As an example:
>>> A = np.array([0,10,20,30,40])
>>> idx = [0, 2, 4]
>>> A[idx]
np.array([0, 20, 40])
So, in your case, you simply need:
angles = anglesp[range(0,50+1,2)]