% function y = lagrange(xd,yd,x)
%
% Evaluates Lagrange interpolation polynomial at some points
%
% Inputs:
%   xd	  absissa of data points
%   yd    ordinate of data points
%   x     abscissa where we want to evaluate Lagrange interp. polynomial
%
% Outputs:
%   y     p(x)
%
%   One way ot test this is to run the following:
%      x = linspace(0,5);
%      xd = [1 2 3 4];
%      yd = [-1 2 -2 5];
%      y = lagrange(xd,yd,x) ;                
%      plot(x,y,xd,yd,'r+')

function y = lagrange(xd,yd,x)

% initialize function values as an array of zeroes of the same size of x
y = zeros(size(x));

% TO BE COMPLETED
