% Matlab function genmat.m (by Q. Ye) function A = genmat(n, c) % % Input parameters: % % n: Matrix dimension % c: condition no. of A % % Output : % % A: a random matrix with condition number c % A = randn(n,n); [U, D, V] = svd(A); for i=0:(n-1) D(i+1,i+1) = c^(-i/(n-1)); end % A=U*D*V';