Let suppose I want to build a set of N orthonormal vectors. Actually I know N-1 orthonormal vectors and I just want to learn the last one.
I should to solve a linear system, setting to zero each scalar product between the N-1 known vectors and that one to find. But how could I do that with Matlab?
EDIT: note that this problem can be seen as a system of linear equations. If U is the (N-1xN) matrix whose rows contain the known vectors, then I should solve the equation Ux = 0, with x the vector to find and 0 the vector of zeros. To do that I used this simple code:
x = U\0
But, in this way, it obviously returns the banal solution 0. I need to the non trivial solution, any idea?
I'm quite sure you want a non-trivial solution to a linear system that satisfies Ax = 0
without x
being a vector of zeros.
This can be done using Singular value decomposition like this:
A = [2 -1 1; 2 -1 1; 3 2 1];
[U S V] = svd(A);
x = V(:,end)
x =
-0.39057
0.13019
0.91132
A*x =
0
0
0