Mercurial > hg > octave-lyh
comparison scripts/general/shift.m @ 12676:2783fa95cab7
Use common code idiom for creating cell array for indexing ND-arrays
* int2str.m, interpft.m, num2str.m, postpad.m, prepad.m, shift.m, fftshift.m,
ifftshift.m, unwrap.m
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 15 May 2011 10:50:30 -0700 |
parents | 9493880928c8 |
children | 04edb15d7966 |
comparison
equal
deleted
inserted
replaced
12674:9493880928c8 | 12676:2783fa95cab7 |
---|---|
58 error ("shift: X must not be empty"); | 58 error ("shift: X must not be empty"); |
59 endif | 59 endif |
60 | 60 |
61 d = sz (dim); | 61 d = sz (dim); |
62 | 62 |
63 idx = cell (); | 63 idx = repmat ({':'}, nd, 1); |
64 for i = 1:nd | |
65 idx{i} = 1:sz(i); | |
66 endfor | |
67 if (b >= 0) | 64 if (b >= 0) |
68 b = rem (b, d); | 65 b = rem (b, d); |
69 idx{dim} = [d-b+1:d, 1:d-b]; | 66 idx{dim} = [d-b+1:d, 1:d-b]; |
70 elseif (b < 0) | 67 elseif (b < 0) |
71 b = rem (abs (b), d); | 68 b = rem (abs (b), d); |