title: Matlab: Index for 5 x 5 grid points
body: <p>For the following:</p>
  
  <pre><code>    x = [0.5 1.5 2.5 3.5 4.5];
  
      for k = 1:1:5
        plot(x(k),x','b^','linewidth', 2)
        hold on
      end
  </code></pre>
  
  <p>similar to:</p>
  
  <pre><code>[x,y] = meshgrid(0.5:1:4.5);
  </code></pre>
  
  <p>How can i index each point (blue triangles) coordinates?</p>
  
  <p><img src="https://i.stack.imgur.com/FAo1V.jpg" alt="enter image description here"></p>
  
  <p>Outcome should be like this:</p>
  
  <pre><code>point1  = [x(1),x(1)]; % [0.5,0.5]
  point2  = [x(1),x(2)]; % [0.5,1.5]
  point3  = [x(1),x(3)]; % [0.5,2.5]
  point4  = [x(1),x(4)]; % [0.5,3.5]
  point5  = [x(1),x(5)]; % [0.5,4.5]
  point6  = [x(2),x(1)]; % [1.5,0.5]
  ...
  point25  = [x(5),x(5)];% [4.5,4.5]
  </code></pre>
  
  <p>I must do something wrong or matlab program isnt letting me index these today.</p>
  
  <pre><code>[~,idx] = length(point(:));
  idxpoint = ind2sub(size(point),idx);
  </code></pre>
  
  <p>Please write a working example.</p>
  
  <p>Thank you in advance.</p>