title: Finding index of giving conditions and specified index set
body: <p>Given a vector <code>x</code> belongs to <code>R^n</code>, an index subset <code>I</code> of <code>S=(1, ..., n)</code>, I want to find the index of the largest elements of <code>x</code> in `I, or the index in the full vector. </p>
  
  <p>In other words, how do I find the index of the largest element of a sub vector in the original vector's index space? </p>
  
  <p>What's the best way to do this in MATLAB?</p>
  
  <p>Currently, I use:</p>
  
  <pre><code>xmax = max(x(I));
  i = I(x(I) == xmax);
  i = i(1);
  </code></pre>
  
  <p>I'm looking for a more efficient way to achieve this. </p>
  
  <h1>Example:</h1>
  
  <pre><code>x = [4, 2, 4];
  S = [1, 2, 3];
  I = [2, 3];
  </code></pre>
  
  <p>The desired output would be 3.</p>