Daniel@0: function M = rand_psd(d, d2, k) Daniel@0: % Create a random positive definite matrix of size d by d by k (k defaults to 1) Daniel@0: % M = rand_psd(d, d2, k) default: d2 = d, k = 1 Daniel@0: Daniel@0: if nargin<2, d2 = d; end Daniel@0: if nargin<3, k = 1; end Daniel@0: if d2 ~= d, error('must be square'); end Daniel@0: Daniel@0: M = zeros(d,d,k); Daniel@0: for i=1:k Daniel@0: A = rand(d); Daniel@0: M(:,:,i) = A*A'; Daniel@0: end