title: Gaussian Elimination in Matlab
body: <p>I am using the matlab code from this book: <a href="http://books.google.com/books/about/Probability_Markov_chains_queues_and_sim.html?id=HdAQdzAjl60C" rel="noreferrer">http://books.google.com/books/about/Probability_Markov_chains_queues_and_sim.html?id=HdAQdzAjl60C</a>
  Here is the Code:</p>
  
  <pre><code>    function [pi] = GE(Q)
  
      A = Q';
      n = size(A);
      for i=1:n-1
        for j=i+1:n
           A(j,i) = -A(j,i)/A(i,i);
        end
           for j =i+1:n
              for k=i+1:n
          A(j,k) = A(j,k)+ A(j,i) * A(i,k);
           end
        end
        end
  
       x(n) = 1;
        for i = n-1:-1:1
          for j= i+1:n
            x(i) = x(i) + A(i,j)*x(j);
          end
         x(i) = -x(i)/A(i,i);
        end
  
        pi = x/norm(x,1);
  </code></pre>
  
  <p>Is there a faster code that I am not aware of? I am calling this functions millions of times, and it takes too much time.</p>