I port a matlab code to mathematica. In the original matlab code, I use ":" to pick up the desired elements in a matrix. In mathematica, I find in the documentation that the span operator is ";;" (without quotation). I have a big nx1 matrix (n is odd), the kth element is the very middle element of the matrix, I am going to pick up all element from k with interval 2, I am currently use the following code
M[[k;;1;;-2]] (* M is the matrix of nx1*) M[[k+2;;n;;2]] (* M is the matrix of nx1*)
It does return the desired elements; however, I want to maintain one index instead. Is that any way to combine the index such that
idx = REVERSE(k;;1;;-2) JOIN k+2;;n;;2
Also, REVERSE mean to reverse the index programatically.