TITLE: How to generate random symmetric positive definite matrices using MATLAB?
QUESTION [43 upvotes]: Could anybody tell me how to generate random symmetric positive definite matrices using MATLAB?

REPLY [7 votes]: For the case where you want a complex matrix (which not all previous answers address), you can do
Q = orth(randn(n) + randn(n)*i);
D = diag(abs(randn(n, 1)) + 0.3);
A = Q*D*Q';

If you want a real matrix, do
Q = orth(randn(n));
D = diag(abs(randn(n, 1)) + 0.3);
A = Q*D*Q';

If you want a semi positive definite matrix, remove the 0.3. One may also change the 0.3 to any other appropriate positive number depending on how positive definite they want the matrix to be guaranteed to be.
This also works in Octave.