title: Matlab speed up nested for loops
body: <p>I have the following nested for loop program and it is taking forever to run. Is there a better way (more efficient) way to code this?</p>
  
  <pre><code>tic 
  ndx = 0;
  for i1 = 1 : 49 - 5
      for i2 = i1 + 1 : 49 - 4
          for i3 = i2 + 1 : 49 - 3
              for i4 = i3 + 1 : 49 - 2
                  for i5 = i4 + 1 : 49 - 1
                      for i6 = i5 + 1 : 49 - 0
                          ndx = ndx +1;
                           number(ndx,1) = i1;
                           number(ndx,2) = i2;
                           number(ndx,3) = i3;
                           number(ndx,4) = i4;
                           number(ndx,5) = i5;
                           number(ndx,6) = i6;
                         %  display([int2str(number(ndx,1)), ' ',  int2str(number(ndx,2)), ...
                          %     ' ',  int2str(number(ndx,3)), ' ',  int2str(number(ndx,4)),...
                          %    ' ',  int2str(number(ndx,5)), ' ',  int2str(number(ndx,6)) ])
                      end
                  end
              end
          end
      end
  end
  toc
  </code></pre>