views:

708

answers:

3

How does one solve the (non-trivial) solution Ax = 0 for x in MATLAB?

A = matrix
x = matrix trying to solve for

I've tried solve('A * x = 0', 'x') but I only get 0 for an answer.

+5  A: 

You can use N = null(A) to get a matrix N. Any of the columns of N (or, indeed, any linear combination of columns of N) will satisfy Ax = 0. This describes all possible such x - you've just found an orthogonal basis for the nullspace of A.

Note: you can only find such an x if A has non-trivial nullspace. This will occur if rank(A) < #cols of A.

Peter
My rank(A) = # cols. How does one "lessen" the value of the rank ? Also null(A) = Empty matrix: 12-by-0.
srand
You should look into low rank approximations. You can use the SVD for this.
Peter
+1  A: 

You can see if MATLAB has a singular value decomposition in its toolbox. That will give you the null space of the vector.

duffymo
That would be SVD, which results in the same result as null(A).
Jacob
They use different numerical methods.
Peter
Not really, null(A) uses svd - http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/null.html
Jacob
My apologies. I assumed it used the QR algorithm.
Peter
I've gone into more detail in my answer
Jacob
+2  A: 

Please note that null(A) does the same thing (for a rank-deficient matrix) as the following, but this is using the svd(A) function in MATLAB (which as I've mentioned in my comments is what null(A) does).

[U S V] = svd(A);
x = V(:,end)

For more about this, here's an link related to this (can't post it to here due to the formulae).

If you want a more intuitive feel of singular and eigenvalue decompositions check out eigshow in MATLAB.

Jacob
thanks for the explanation :)
srand