%CHEBYREG2 %X = chebyreg(x,minx,maxx,n) returns a t-by-n matrix. Element (i,j) of X, for i=1,...,t and j=1,...,n is given by T_j(r_i) where T_j denotes the Chebyshev polynomial of the first kind of order j and r_i denotes 2 * (x(i)-minx)/(maxx-minx)-1 and t is the length of x. function X = chebyreg2(x,minx,maxx,n); t=length(x); z = 2 * (x-minx) / (maxx-minx) -1; for i=1:t X(i,1) = 1; X(i,2) = z(i); for j=3:n X(i,j) = 2*z(i)*X(i,j-1)-X(i,j-2); end end