function dy = deriv(y, x) dy = diff(y) ./ (x(2) - x(1)); dy = dy([1 1:end]); end