% Plot condition number of Vandermonde matrix
cn = [];
for n=1:45
  x = linspace(0,n*pi/2,n+1)';
  V = repmat(x,1,n+1).^repmat((n:-1:0),n+1,1);
  cn = [cn; n cond(V) condnewtonmatrix(x)];
end
figure; semilogy(cn(:,1),cn(:,2),'r*',cn(:,1),cn(:,3),'b+');
set(gca,'fontsize',14);
xlabel('{\bf n}');
ylabel('{\bf cond_{2}(M)}');
title('condition number of interpolation matrix');
legend('Vandermonde matrix','Newton matrix','location','best');