function val = evalPoly(coef,x)
% val is the value of a polynomial with coefficients coef evaluated at x.
% coef is a vector where coef(1) is the coefficient of the term x^0.

val= coef(1);
xpow= 1;
% Accumulate val one term at a time
for k= 2:length(coef)
    %val= val + coef(k)*x^(k-1);
    xpow= xpow*x;
    val= val + coef(k)*xpow;
end