function tbl = DividDif(x,y) % usage: DividDif(x,y) % description: for input vectors x of abscissas and y of ordinates % of function f(x), returns a zero padded matrix whose ith row % is the ith diagonal of a divided difference table for the data. n = length(y); if (n ~= length(x)) disp('There is a size mismatch in abscissas and ordinates'); return; end; x = x(:); % make x,y columns y = y(:); tbl = zeros(n,n+1); tbl(:,1) = x(:); tbl(:,2) = y(:); for k = (3:n+1) tbl(1:n-k+2,k) = (tbl(2:n-k+3,k-1)-tbl(1:n-k+2,k-1))./(x(k-1:n)-x(1:n-k+2)); end;