Mercurial > hg > octave-nkf
diff scripts/signal/fftshift.m @ 11469:c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Jan 2011 12:41:21 -0800 |
parents | be55736a0783 |
children | fd0a3ac60b0e |
line wrap: on
line diff
--- a/scripts/signal/fftshift.m +++ b/scripts/signal/fftshift.m @@ -18,22 +18,22 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} fftshift (@var{v}) -## @deftypefnx {Function File} {} fftshift (@var{v}, @var{dim}) -## Perform a shift of the vector @var{v}, for use with the @code{fft} +## @deftypefn {Function File} {} fftshift (@var{x}) +## @deftypefnx {Function File} {} fftshift (@var{x}, @var{dim}) +## Perform a shift of the vector @var{x}, for use with the @code{fft} ## and @code{ifft} functions, in order the move the frequency 0 to the ## center of the vector or matrix. ## -## If @var{v} is a vector of @math{N} elements corresponding to @math{N} +## If @var{x} is a vector of @math{N} elements corresponding to @math{N} ## time samples spaced of @math{Dt} each, then @code{fftshift (fft -## (@var{v}))} corresponds to frequencies +## (@var{x}))} corresponds to frequencies ## ## @example ## f = ((1:N) - ceil(N/2)) / N / Dt ## @end example ## -## If @var{v} is a matrix, the same holds for rows and columns. If -## @var{v} is an array, then the same holds along each dimension. +## If @var{x} is a matrix, the same holds for rows and columns. If +## @var{x} is an array, then the same holds along each dimension. ## ## The optional @var{dim} argument can be used to limit the dimension ## along which the permutation occurs. @@ -43,7 +43,7 @@ ## Created: July 1997 ## Adapted-By: jwe -function retval = fftshift (V, dim) +function retval = fftshift (x, dim) retval = 0; @@ -55,29 +55,29 @@ if (!isscalar (dim)) error ("fftshift: dimension must be an integer scalar"); endif - nd = ndims (V); - sz = size (V); + nd = ndims (x); + sz = size (x); sz2 = ceil (sz(dim) / 2); idx = cell (); for i = 1:nd idx{i} = 1:sz(i); endfor idx{dim} = [sz2+1:sz(dim), 1:sz2]; - retval = V (idx{:}); + retval = x(idx{:}); else - if (isvector (V)) - x = length (V); + if (isvector (x)) + x = length (x); xx = ceil (x/2); - retval = V([xx+1:x, 1:xx]); - elseif (ismatrix (V)) - nd = ndims (V); - sz = size (V); + retval = x([xx+1:x, 1:xx]); + elseif (ismatrix (x)) + nd = ndims (x); + sz = size (x); sz2 = ceil (sz ./ 2); idx = cell (); for i = 1:nd idx{i} = [sz2(i)+1:sz(i), 1:sz2(i)]; endfor - retval = V (idx{:}); + retval = x(idx{:}); else error ("fftshift: expecting vector or matrix argument"); endif