title: Apply function on all matrix elements
body: <p>I want to apply a function on each element in a matrix. I've written the following code:</p>
  
  <pre><code>function p = an(x)
      p= x + 1;
  end
  </code></pre>
  
  <p>The matrix is for example:</p>
  
  <pre><code>B = [1 2 3; 3 4 5; 6 7 8]
  </code></pre>
  
  <p>When I try to do this:</p>
  
  <pre><code>arrayfun(@an , B(1, :) , B(2, :), B(3, :))
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p><code>??? Error using ==> arrayfun<br/>
    Undefined function or method 'an' for input arguments of type 'double'.</code></p>
  </blockquote>
  
  <p>I can't understand why. How I can fix it? Is there a easier way to do it?</p>