MATLAB: How to use circshift in matlab

priodic data

I have a array of indeces, so they must be positive, but some of them are negative, for instance for a array of m elements, I want to say if i=-1 put i=M-1, and if i=-2 put it M-2, how can I use circshift?

Best Answer

What you're trying to do does not seem to require CIRCSHIFT at all, but merely
mod(i,M)