title: Select Diagonal Elements of a Matrix in MATLAB
body: <p>Consider the following matrix in MATLAB:</p>
  
  <p>01 02 03 04 05 06 07</p>
  
  <p>08 09 10 11 12 13 14</p>
  
  <p>15 16 17 18 19 20 21</p>
  
  <p>22 23 24 25 26 27 28</p>
  
  <p>29 30 31 32 33 34 35</p>
  
  <p>36 37 38 39 40 41 42 </p>
  
  <p>43 44 45 46 47 48 49</p>
  
  <p>I have to generate directional variograms for such 7 x 7 windows(moving) of an image. I will use <code>nlfilter</code> for the process but for developing the function to calculate variograms I am not able to decide how to select elements in the window. For example when I consider the central value 25, in EW direction I have to consider only 25, 26, 27 and 28; in NE direction I have to consider only 25, 19, 13 and 07 when the lag chosen is 1. Is there any standard command to do so?</p>