VDIFF Length-preserving first central difference. DX=VDIFF(X,DIM) differentiates X along dimension DIM using the first central difference; DX is the same size as X. [D1,D2,...,DN]=VDIFF(X1,X2,...,XN,DIM) for multiple input variables also works. VDIFF(X1,X2,...,DIM); with no output arguments overwrites the original input variables. DXDT=VDIFF(DT,...) optionally uses scalar timestep DT to approximate a time derivative, i.e. DXDT equals DX divided by DT. _____________________________________________________________________ First and last points The first and last points must be treated differently, as the central difference is not defined there. Three different methods can be used. VDIFF(...,STR) specifies which method to use. 'endpoint' uses the first forwards / first backwards difference at the first and last point, respectively. 'periodic' treats the array as being periodic along dimension DIM, so that the central difference is defined at endpoints. 'nans' fills in the first and last values with NANs. The default behavior is 'endpoint'. _____________________________________________________________________ 'vdiff --t' runs some tests. Usage: x=vdiff(x,dim); x=vdiff(dt,x,dim); x=vdiff(dt,x,dim,'periodic'); __________________________________________________________________ This is part of JLAB --- type 'help jlab' for more information (C) 2000--2015 J.M. Lilly --- type 'help jlab_license' for details