The basic slice syntax is i:j:k where i is the starting index, j is the stopping index, and k is the step ( k!=0). This selects the m elements (in the corresponding dimension) with index values i,i + k, …, i + (m - 1) k where and q and r are the quotient and remainder obtained by dividing j - i by k: j - i = q k + r, so that i + (m - 1) k < j
Negative i and j are interpreted as n + i and n + j where n is the number of elements in the corresponding dimension. Negative k makes stepping go towards smaller indices.