function y = ChebyshevEval(n,x); % % Evaluate Chebyshev polynomails up to degree n for a given x. % % written by Ming Gu for Math128B, Spring 2009 % y = ones(length(x),n+1); if (n==0) return; end y(:,2) = x; if (n==1) return; end tx = 2*x; for k=3:n+1 y(:,k) = tx.*y(:,k-1)-y(:,k-2); end