function a = vander(x,y)

%  This function returns the coefficients of the Lagrange

%  polynomial found using the matrix form.

%  The result will give p(x) = a(1) + a(2)*x + a(3)*x^2 + ... + a(n+1)*x^n

%  Usage:

%     a = vander(x,y)


temp = size(y);
if temp(1) < temp(2)
  y = y';
end


np1 = max(size(x));


powers = 0:np1-1;

for i=1:np1

 mat(i,:) = x(i) .^ powers;

end

a = mat \ y;