function p=lagrangeinterp(xx,x,c)
%Calculate values using Lagrange's polynomial interpolation
% x -> column vector of values along x-axis
% c -> Langrange's interpolating coefficients for polynomial fit to data
% xx -> column vector of interpolation points required
% p  -> Interpolated value corresponding to xx value
n=length(x);
m=length(xx);
p=diag(zeros(m));
for k=1:m
   d=diag(eye(n));
   for j=1:n
      for i=1:n
         if(i~=j)
            d(j)=d(j)*(xx(k)-x(i));
         end
      end
      p(k)=p(k)+c(j)*d(j);
   end
end

