title: how to filter array using anonymous function in Matlab?
body: <p>I want to write a function, preferably an anonymous one, that filters an array. It's hard to say in words, but it's like this:</p>
  
  <pre><code>f = @(x) { if (x &gt; 1) x+1 }; 
  a = [ 1, 2, 3];
  f(a) % 
  ==&gt; [ 1 3 4]
  </code></pre>
  
  <p>The key points I want is:</p>
  
  <ul>
  <li>want the function to receive a number
  or a string </li>
  <li>but when given an array,
  the function will apply itself to
  each element in the array and returns
  another array.</li>
  </ul>
  
  <p>This is similar to the way the function log() works:</p>
  
  <pre><code>&gt;&gt; log(1) 
  ans =
        0 
  &gt;&gt; log([1,2,3])
  ans =
        0    0.6931    1.0986
  </code></pre>
  
  <p>Thank you</p>