Diff


Contents

Description

Returns a dataset that contains the difference between adjacent elements in dataset. Optional parameter n allows for padding to return N-1, N, or N+1 elements:


If option n is omitted, returns N-1 elements (the function is calculated using n = 0).

Syntax

Dataset diff(dataset vd[,n])

Parameters

ds

A dataset or a range pointing to a single dataset.

Return

Returns a dataset.

Examples

col(1) = data(1,100);
col(2) = 1.23 + 4.56 * col(1) - 7.89 * col(1) * col(1);
col(3) = diff(col(2));
col(4) = diff(col(3));
col(5) = col(4) / 2;
dataset vd = {1,-2,4,-3,1,2,5,3,-2,-1};
col(A)=diff(vd);
col(B)=diff(vd,0);
col(C)=diff(vd,1);
col(D)=diff(vd,2);
col(E)=diff(vd,3);