how to use circshift in matlab
조회 수: 2 (최근 30일)
이전 댓글 표시
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?
댓글 수: 3
채택된 답변
Matt J
2012년 12월 21일
편집: Matt J
2012년 12월 21일
What you're trying to do does not seem to require CIRCSHIFT at all, but merely
mod(i,M)
댓글 수: 1
Roger Stafford
2012년 12월 22일
If positive integers are desired which must always fall in the range 1<=k<=M, then a modification of the 'mod' function would seem to be called for. To "add" p to k, do this:
k_plus_p = mod(k+p-1,M)+1
This gives the alteration to an index k of an element of an array which occurs with a circular shift of amount p.
Roger Stafford
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!