% % Evaluate Newton's interpolating polynomial at % given points. % % function [p] = NewtIntPolEval( x, a, z ) % % input: % x: vector containing the % interpolation points % a: vector of coefficients of Newton's % interpolating polynomial % z: vector of points at which Newton's % interpolating polynomial has to be % evaluated % % output: % p: vector of values of Newton's % interpolating polynomial % % function [p] = NewtIntPolEval( x, a, z ); n = size(x(:),1); if size(a(:),1) ~= n error(' NewtIntPolEval: Dimension of a must be equal to dimension of x') end p = a(n) * ones(size(z)); for i = n-1:-1:1 p = p .* ( z - x(i) * ones(size(z)) ) + a(i); end