MATLAB: How to solve system Ax=0 under the constraint that sum(x)=1

linear algebranull solution

A is [NxN] matrix whose coefficients I know and x is a [Nx1] vector of the unknowns I want to solve for.
I have been exploring the option [u,s,v] = svd(A); but I don't know how to impose the constraint.
I have also tried: x = lsqlin(A,zeros(n1,1),diag(ones(n1,1)),zeros(n1,1)); but that doesn't work either.
Thanks for your time!

Best Answer

In order to have a nonzero solution to A*x = 0, the matrix A must be singular, that is, its determinant must be zero. If its rank is N-1, you can find a single vector solution using the 'null' function. Assuming the sum of the vector's elements is nonzero, you can normalize it by dividing the elements by this sum. If the rank is less than N-1, the solution space is more than one dimensional and a solution with sum 1 would not be unique.