Search code examples
matlabmatrixorthogonal

How to generate an orthonormal matrix that is orthogonal to vector (1;...;1) in MATLAB?


I wonder how to generate matrix A of size n*(n-1) in MATLAB such that:

transpose(A) * ones(n,1) = zeros(n-1,1)

transpose(A) * A = eye(n-1,n-1) 

Solution

  • The nullspace operator exactly does this, it finds the matrix of all orthonormal vectors:

    >> null([1;1;1;1]')
    ans =
    -0.50000  -0.50000  -0.50000
     0.83333  -0.16667  -0.16667
    -0.16667   0.83333  -0.16667
    -0.16667  -0.16667   0.83333