title: Octave index out of bounds
body: <p>The program is an optimized gradient descent.</p>
  <p>Here is the code :</p>
  <pre><code>    clear all
      close all
      [x,y] = meshgrid(-2:0.1:2);                                            
     z = x.^2 + 100*y.^2;                                          
     n = 1;
     k(n)=0.01;
     arret = 0.0001;                                                         
     mesh(x,y,z);                                                            
     [x1(n),y1(n)] = ginput(1);                                             
     diff_x(n) = 2*x1(n);                                                   
     diff_y(n) = 200*y1(n);                                                 
     while sqrt(diff_x(n)^2 + diff_y(n)^2) &gt; arret &amp;&amp; n &lt; 30
       k(n) = sqrt(diff_x(n)^2 + diff_y(n)^2)/(8*x1(n).^2+2*10.^6*y1(n).^2);         
       x1(n+1) = x1(n) - k(n)*diff_x(n);                                    
       y1(n+1) = y1(n) - k(n)*diff_y(n);    
       n = n+1;  
       diff_x(n) = 2*x1(n);
       diff_y(n) = 200*y1(n);
       z1(n) = x1(n).^2 + 100*y1(n).^2;                                     
       plot3(x1(n),y1(n),z1(n));                                             
     end
  
     x1(n)
     y1(n)
     n
  </code></pre>
  <p>So I got this and I don't understand why.</p>
  <blockquote>
  <p>error: GradientPasOptFinal2: A(I): index out of bounds; value 2 out of bound 1</p>
  <p>error: called from:</p>
  <p>error:   error:   C:\Octave\octave-3.8.2\GradientPasOptFinal2.m at line 13, column 8</p>
  </blockquote>
  <p><strong>SOLVED</strong> : the k(n) between y1(n) and n was the reason, i don't know why, but now the program works, thank you !</p>