function d = vdgrid(N,n,sigma,cent)

% function d = vdgrid(N,n,sigma,[cent])
% N:       Matrix size
% n:       number of samples
% sigma:   sigma in DK units
% cent:    number of center points to guarantee appear
%
% Output:  vector of k space locations in units of fully sampled Delta K
%          desired density is Gaussian with width sigma
%          sigma=0 or inf or n=N gives uniform distribution round(-N/2 + (0:(n-1)) * (N-1)/(n-1))

if n>N
    error('n is greater than N');
end

if sigma==0 | sigma==inf | n==N
    d = round(-N/2 + (0:(n-1)) * (N-1)/(n-1));
    return;
end

if nargin<4
	cent = 0;
end;

if cent<0 | cent>n
	cent = 0;
end;

d = round(-(cent+1)/2)+(1:cent);
tot=length(d);
while tot<n
    samp = round(sigma * randn(1,n-tot));
    d = unique([d samp(find(samp>=(-N/2) & samp<(N/2)))]);
    tot = length(d);
end

return;

