Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solving a matrix in MATLAB?

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.

like image 798
Venus Avatar asked Oct 04 '09 01:10

Venus


People also ask

How do you solve matrices in MATLAB?

Description. X = linsolve( A , B ) solves the matrix equation AX = B, where B is a column vector. [ X , R ] = linsolve( A , B ) also returns the reciprocal of the condition number of A if A is a square matrix. Otherwise, linsolve returns the rank of A .

How do you make a matrix equation in MATLAB?

[ A , b ] = equationsToMatrix( eqns ) converts equations eqns to matrix form. eqns must be a linear system of equations in all variables that symvar finds in eqns . [ A , b ] = equationsToMatrix( eqns , vars ) converts eqns to matrix form, where eqns must be linear in vars .

What is the matrix function in MATLAB?

Matrix function is a scalar function that maps one matrix to another. Suppose, f(x) , where x is a scalar, has a Taylor series expansion. Then the matrix function f(A) , where A is a matrix, is defined by the Taylor series of f(A) , with addition and multiplication performed in the matrix sense.


2 Answers

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.

like image 154
Jacob Avatar answered Oct 06 '22 21:10

Jacob


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.

like image 43
Peter Avatar answered Oct 06 '22 19:10

Peter