function d=DD(n,N,c)
% DD  finite difference coefficients
% usage:: d=DD(n,N,c)
%
% Calculate finite difference coefficients.  n==order of derivative,
% N==number of points, c==center from list 1:N not accurrate enough for
% large N>=9, use Mathematica script DD.m or correct using round:
% (e.g., d=round(DD(1,11,6)*140*3*3)/140/3/3). 

% revision history:
% 10/24/00 Mark D. Shattuck <mds>   DD.m
%          nb: based on Mathematica script developed by mds in 1989

d=0:N-1;

[ix iy]=ndgrid(d-c+1,d);

iiy=iy;
iiy(iiy==0)=1;

d=(d==n)/(ix.^(iy)./cumprod(iiy,2));

