Mercurial > hg > octave-nkf
diff scripts/signal/fftshift.m @ 12540:b3c158b8941c
Add tests for fftshift.m.
author | Robert T. Short <octave@phaselockedsystems.com.com> |
---|---|
date | Sat, 26 Mar 2011 06:42:35 -0700 |
parents | 189baf055143 |
children | 2783fa95cab7 914c0b103a3d |
line wrap: on
line diff
--- a/scripts/signal/fftshift.m +++ b/scripts/signal/fftshift.m @@ -83,3 +83,49 @@ endif endfunction + +%!test +%! x = [0:7]; +%! y = fftshift (x); +%! assert(y, [4 5 6 7 0 1 2 3]); +%! assert(fftshift (y), x); + +%!test +%! x = [0:6]; +%! y = fftshift (x); +%! assert(y, [4 5 6 0 1 2 3]); +%! assert(fftshift (y), [1 2 3 4 5 6 0]); + +%!test +%! x = [0:7]'; +%! y = fftshift (x); +%! assert(y, [4;5;6;7;0;1;2;3]); +%! assert(fftshift (y), x); + +%!test +%! x = [0:6]'; +%! y = fftshift (x); +%! assert(y, [4;5;6;0;1;2;3]); +%! assert(fftshift (y), [1;2;3;4;5;6;0]); + +%!test +%! x = [0:3]; +%! x = [x;2*x;3*x+1;4*x+1]; +%! y = fftshift (x); +%! assert(y, [[7 10 1 4];[9 13 1 5];[2 3 0 1];[4 6 0 2]]); +%! assert(fftshift (y), x); + +%!test +%! x = [0:3]; +%! x = [x;2*x;3*x+1;4*x+1]; +%! y = fftshift (x,1); +%! assert(y, [[1 4 7 10];[1 5 9 13];[0 1 2 3];[0 2 4 6]]); +%! assert(fftshift (y,1), x); + +%!test +%! x = [0:3]; +%! x = [x;2*x;3*x+1;4*x+1]; +%! y = fftshift (x,2); +%! assert(y, [[2 3 0 1];[4 6 0 2];[7 10 1 4];[9 13 1 5]]); +%! assert(fftshift (y,2), x); +