function y = polyvalbyed(P,x)
% POLYVALBYED  Re-implementation by Ed of the built-in polyval.
%     It is essentially the same as FASTEVAL, which is to say
%     it is an implementation of Horner's method, except for
%     reordering the coefficients to match POLYFIT/POLYVAL.
%
% Example:
%   >> x = [0.0 0.1 0.2 0.3 0.4];  P = polyfitbyed(x,sin(x),4)
%   >> polyvalbyed(P,0.25)
% You can compare this result to that from the POLYFIT/POLYVAL pair.
%
% See also: POLYFITBYED

n = length(P) - 1;
y = P(1);
for j=2:n+1
  y = P(j) + x * y;
end
