Hi,
I need to create a random orthonormal vector (i) to a given unit vector and (ii) with (maximal) n-2 predetermined components. For example, say I have the unit vector v1=[-0,52 0,72 -0,19 0,37 -0,18]' (rounded to two digits) and I have the vector v2 with lets say 2 predetermined components that are non-zero, v2=[a b c 0.45 -0.09]. Thus, there should be infinite many solutions for a, b, and c such that v1`*v2=0.
I would like to find an efficient way to generate such a random orthonormal vector v2 where the elements a, b, and c are drawn from a uniform distribution.
I have tried the following:
% start with a random matrix
X = randn(3);% add some predetermined values
predet=[.4,.5,.4;-.2,-.1,-.2];V=[X;predet];% normalize vectors
v1=V(:,1)/norm(V(:,1));v2=V(:,2)/norm(V(:,2));% find a random solution for v1'*v2==0 with 3 random entries of v2
check=0;while check<1 random = -1 + (1-(-1)).*rand(3,1); v2=[random; v2(4:5)]; % check whether v2 is orthogonal to v1 and v2 has norm 1
if norm(v2)>0.9999 && norm(v2)<1.0001... && v1'*v2<=0.0001 && v1'*v2>=-0.0001 check=1; endend
However, so far the solution is only a very bad approximation and the algorithm is very slow. Any help on this or suggestions would be very much appreciated.
Best Answer