### remove meshgrid from fftfreq

parent 353e246c
 function varargout = fftfreq(N, dx, computeMeshgrid) function varargout = fftfreq(N, dx) % FFTFREQ creates a grid of Fourier-frequencies corresponding to the sampling points % of an n-dimensional FFT of given size. % % ``varargout = fftfreq(N, dx, computeMeshgrid)`` % ``varargout = fftfreq(N, dx)`` % % % Parameters ... ... @@ -12,16 +12,12 @@ function varargout = fftfreq(N, dx, computeMeshgrid) % dx : float or tuple of floats, optional % Underyling spacing in real-space, possibly different along each grid-dimension. % Default = ones(size(N)). % computeMeshgrid : tuple of non-negative integers, optional % Return Fourier-frequency grid as meshgrid (case: true) or merely as coordinate vectors % for the different dimensions? Default = false. % % % Returns % ------- % varargout : tuple of numerical arrays % numel(N) vectors of length N(1), N(2),... that span the Fourier-grid % OR, if computeMeshgrid == true, the meshgrid corresponding to these vectors % % See also % -------- ... ... @@ -64,19 +60,11 @@ dx = dx(:).' .* ones([1,numel(N)]); ndim = numel(N); % Grid in Fourier space xi = cell(1, ndim); for jj = 1:ndim xi{jj} = ifftshift( ( -floor(0.5*N(jj)) : floor(0.5*(N(jj)-1)) ).' * ( 2*pi / (N(jj)*dx(jj)) ) ); end % Optionally assemble ndgrid (occupies more memory!) if nargin == 3 && computeMeshgrid [xi{:}] = ndgrid(xi{:}); elseif ndim > 1 for jj = 1:ndim xi{jj} = reshape( xi{jj}, [ones([1,jj-1]), N(jj), ones([1,ndim-jj])] ); end end % Unpack cell-array varargout = xi; ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!