I have some variables to find like x= [1x16 (x1,x2,x3,....x16 variables)] with condition that x1+x2+x3+....x16=1. I have also 16x16 matrix Q= [16x16 (real values)].
I need to solve the equation 'x*Q=x' as shown here. How can I solve it in Matlab or in any other language easily?
By transposition, your equation is equivalent to Q'y=1y where y:=x' (a column vector) where Q' is the transpose of Q (matlab notation...) which means that y is an eigenvector associated with eigenvalue 1 for matrix Q'. Such an eigenvector always exists for a Markov matrix. Let s be the sum of the entries of column vector y. Two cases can occur :
either s is not 0 ; then it suffices to divide all coordinates of y by s : we obtain a vector that is still an eigenvector, with a coordinate sum equal to 1.
or s=0 and there is no solution to your problem.
Here is a Matlab program that does the work for a 3 x 3 matrix :