function yd=deriv2p(x,y,h)
% Derivada del vector y usando la fórmula de dos puntos
%  T. C. O'Haver, 1988.
% Example:
%  x = [1 2 4 7 10 14 20 30];y = 2*x;plot(x,y,'o-');dy=deriv(x,y)
% ans =
%      2     3     5     6     7    10    16    20
% Note: to compute the derivative of y with respect to x, use derivxy.m
% x = [1 2 4 7 10 14 20 30];y = 2*x;derivxy(x,y)
% ans =
%      2     2     2     2     2     2     2     2
n=length(x);

if (h>0)
    yd = diff(y,1)./diff(x,1);
    yd(n)=(y(n)-y(n-1))/(x(n)-x(n-1));
  else
    yd = diff(y,1)./diff(x,1);
    yd =[(y(2)-y(1))/(x(2)-x(1)),yd];
  endif
  
