[Math] Generating a random singular matrices using matlab

MATLAB

Could anybody tell me that How one can generate a random singular matrices using matlab? I know that using rand(n) we can generate a random matrix of order n. But I found that these random matrices are non singular while I am interested in generating random singular matrices of higher order. Is there any command through which we can generate a random singular matrices? I need help.

Thanks a lot

Best Answer

If you're not too worried about the distribution of the matrix, you could just generate an $n-1 \times n$ matrix, and let the $n$th row be the sum of the others.

n = 3;
A = rand(n-1,n);
A(end+1,:) = sum(A);
Related Question