Question

I want to generate random mean-preserving orthonormal matrix A in MATLAB, such that :

A*trans(A) = I, && A*1=1 (1 is the vector in which all arrays equal 1)

I would appreciate any suggestions.

Was it helpful?

Solution

I found the answer here: http://mathforum.org/kb/message.jspa?messageID=4575590

They proposed the following function:

function [U] = genU(m)
V1 = ones(m, 1) / sqrt(m);
[V, L] = svd(V1);
[Rm1, tmp] = qr(randn(m - 1, m - 1));
U = V * blkdiag(1, Rm1) * V';

Where m is the desired dimension.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top