# Generating $n\times n$ random matrix with rank $n/2$ using matlab

Can we generate $n \times n$ random matrix having any desired rank? I have to generate a $n\times n$ random matrix having rank $n/2$.

Thanks for your time and help.

Generate $U,V$ random matrices of size $n \times n/2$, then almost surely $A = U \cdot V^T$ is of rank $n/2$.
• (+1) Unless, of course, $n$ is odd. ;-) – Cameron Buie Apr 16 '13 at 5:39