title: extract a pair from list in matlab
body: <p>i wanted to ask this:
   I have in mathematica :</p>
  
  <pre><code>step := {{0, 1}, {1, 0}, {0, -1}, {-1, 0}} [[RandomInteger[ {1, 4}] ]]
  
  step  --&gt; this takes one list from above (for example {0,1})
  
  steps2D[n_] := Table[step, {n}]
  </code></pre>
  
  <p>and i did:</p>
  
  <pre><code>a=[0,1];b=[1,0];c=[0,-1];d=[-1,0];
  list=[a;b;c;d]
  step=@ (rand) rand(1,list) --&gt;&gt; i must extract from here randomly one pair..
  step
  
  steps2D=@ (n) arrayfun(step,n);
  </code></pre>
  
  <p>I have 2 problems:
  1) I can't extract from my list randomly one pair.
  2) I don't know if i have the step2D right.</p>
  
  <p>EDIT-->> The code continues :</p>
  
  <pre><code>Walk2D[n_] := FoldList[Plus, {0, 0}, steps2D[n]]
  Walk2D[10]
  LastPoint2D[n_] := Fold[Plus, {0, 0}, steps2D[n]]
  LastPoint2D[100]    
  </code></pre>
  
  <p>I did this :</p>
  
  <pre><code>Walk2D=@ (list,n) cumsum(steps2D(list,n));
  Walk2D(list,10)
  
  LastPoint2D = @ (Walk2D) (Walk2D(end));
  walk1=Walk2D(list,100);
  LastPoint2D(walk1)  --&gt;&gt; This gives me only one number and not a pair as it should
  </code></pre>