The Matlab "diff" function is basically the Backward difference formula. There are much more accurate ways to compute numerical derivatives.
If you like, you can program your own function(s). The central difference calculation is much better than either forward or backward method. Use Forward difference to calculate the derivative at the first point, and backward difference to calculate the derivative at the last point. Everywhere in between, use the central difference formula. This allows you to compute a derivative at every point in your vector, and will provide better results than using recursive applications of "diff".
If you are interested in this method, I can provide equations for even better accuracy than these.
[EDIT] Here is a slightly more accurate version for the Forward/Backward difference:
Your Matlab function would look somethng like this:
function dy = Nderiv2(y,h)
n = length(y);
for i=1:n
switch i
case 1
dy(i) = ...
case n
dy(i) = ...
otherwise
dy(i) = ...
end
end
end
The third derivative function is similar, except that the central difference formula uses a range on y of y(i-2), y(i-1) y(i+1) y(i+2), so you need two points on either side of y(i) to perform this calculation.
function dy = Nderive3(y,h)
n = length(y);
for i=1:n;
switch i
case {1, 2}
dy(i) = ...
case {n-1, n}
dy(i) = ...
otherwise
dy(i) = ...
end
end
end