how to generate a random matrix with Orthogonalized rows using Gram-Schmidt algorithm in Matlab

无人久伴 提交于 2019-12-02 00:55:15

问题


I want to generate a M*N matrix (M is not equal to N) with following constraints in MATLAB:

Step 1. Set each entry of the matrix to an i.i.d. N(0,1) value.

Step 2. Orthogonalize the M rows of the matrix using the Gram-Schmidt algorithm.

Step 3. Normalize the rows of the matrix to unit length.

I do not know how to implement second step of above.

Any help is appreciated.


回答1:


You might want to look at orth:

A = randn( m, n );  % random iid ~N(0,1)
oA = orth( A.' ).'; % orthogonal rows
nA = bsxfun( @rdivide, oA, sqrt( sum( oA.^2, 2 ) ) ); % normalize to unit length


来源:https://stackoverflow.com/questions/24987414/how-to-generate-a-random-matrix-with-orthogonalized-rows-using-gram-schmidt-algo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!