function output=mydiff(x,y)

% computes the derivative of y with respect to x (should be row or column 
% vectors of the same length.) 
% Uses a centered scheme except for the edge points. 

 n = length(x);
 output = zeros(size(x));
 output(2:n-1) = (y(3:n)-y(1:n-2))./(x(3:n)-x(1:n-2)); 
 output(1) = (y(2)-y(1))/(x(2)-x(1));
 output(n) = (y(n)-y(n-1))/(x(n)-x(n-1));

