Getting specific basis vectors of the kernel in MatLab

244 Views Asked by At

Im interested in getting the basis vectors of the kernel of a given matrix A. I often used null(A) which works fine. Im more interested to get exactly the basis vectors that you would get when calculating the homogeneous system of linear equations by hand.

For example A = [2,-1,-1 ; 0,0,0 ; 2,-1,-1]. For that MatLab gives me

null(A) = 0.5774 0 0.5774 -0.7071 0.5774 0.7071

I tried to use kernel(rref(A)) where rref(A) is just [1,-0.5,-0,5 ; 0,0,0 ; 0,0,0]. For this matrix I do get

null(rref(A)) =
0 -0.5774 -0.7071 -0.5774 0.7071 -0.5774

When solving the system of linear equations A*b = 0using pencil and paper I get

0.5 0.5 0 1 1 0

as the kernel of A. I want to get the exact same result from matlab. Is there a function that get me there or can someone help me with the coding? From linear algebra I know that dim(kern(A)) = length(A) - rank(A) so we can consider the last r = dim(kern(A)) variables to be free to choose. I would like to choose them to be 1. How do I get to that basis vectors?