function Y = corthpoly2(N,M)
% Chebychev polynomials to order N-1 over M input samples
%  returned in rows of matrix Y
inc = 2/(M-1);
x = -1:inc:1;
Y = zeros(N,M);

Y(1,:) = 1; % T_0;
for n=2:N
  Y(n,:) = polyval(ChebyshevPoly(n-1),x);
endfor

Y(1,:) = Y(1,:)/sqrt(sum(Y(1,:)));
for n=2:N
 Y(n,:) = Y(n,:)-mean(Y(n,:));
 Y(n,:) = Y(n,:)/sqrt(Y(n,:)*Y(n,:)');
endfor


