title: Apply different functions to columns of a matrix
body: <p>I have a matrix, for example, "A", with size 5 * n, where "n" is a large number. I want to apply functions to the columns of "A", is <code>for</code> loop the best solution?</p>
  
  <p>To be specific, assume</p>
  
  <pre><code>A = randn(5, 10000);
  B = randn(5, 5000);
  ix = cell(1, 10000);
  for i =1:10000
      n = poissrnd(5);
      ix{i} = datasample(1:5000, n, 'replace', false);
  end
  </code></pre>
  
  <p>and I want to do the following:</p>
  
  <pre><code>for i = 1:10000
      A(:, i) = B(:, ix{i}) * B(:, ix{i})' * A(:,i);
  end
  </code></pre>
  
  <p>The function in this example is just <code>B(:, ix{i}) * B(:, ix{i})'</code> and "ix" is a cell of vectors which are indices, for example, "ix{i}" could be <code>[1, 3, 11, 20]</code>.</p>