% Given the nodes belonging to [-1,1], calculate the diff Matrix function D = Generalized_Diff_Mat(xs) %% n = length(xs) - 1; xs = xs(:); %ensure that xs is a column vector X = repmat(xs,1,n+1); dX = X-X' + eye(n+1); aj = prod(dX).'; D = (aj*(1./aj).')./dX; D = D - diag(sum(D.')); %% Teste