title: How to make for loops go backwards?
body: <p>I wrote some code for Matrix backwards calculation but for some reason it goes from 3 to 2 but it won't go from 3 to 1. If I tell it to go from 3 to 1 it completely jumps instructions.</p>
  
  <pre><code>function [x] = backwards(U,b)
  
  [n,n]=size(U);
  x(n)=b(n)/U(n,n);
  
  for i=n-1:1     
             sum=0;
          for k=i+1:n
              sum=sum+(U(i,k)*x(k));
              x(i)=(b(i)-sum)/U(i,i);
          end      
  end
  
  fprintf('solution:');
  fprintf('\n');
  disp(x');
  
  end
  
  </code></pre>