title: Loopless function calls on vector/matrix members in Matlab/Octave
body: <p>I came into matrix world from loop world (C, etc)</p>
  
  <p>I would like to call a function on each individual member of a vector/matrix, and return the resulting vector/matrix.</p>
  
  <p>This is how I currently do it:</p>
  
  <pre><code>function retval = gauss(v, a, b, c)
    for i = 1:length(v)
      retval(i) = a*(e^(-(v(i)-b)*(v(i)-b)/(2*c*c)));
    endfor
  endfunction
  </code></pre>
  
  <p>Example usage:</p>
  
  <pre><code>octave:47&gt; d=[1:1000];
  octave:48&gt; mycurve=gauss(d, 1, 500, 100);
  </code></pre>
  
  <p>Now, all advice on MATLAB/Octave says: STOP whenever you catch yourself using loops and think of a better way of doing it.</p>
  
  <p>Thus, my question: <strong>Can one call a function on each member of a vector/matrix and return the result in a new vector/matrix all at once without using explicit loops?</strong></p>
  
  <p>That is I am looking for something like this:</p>
  
  <pre><code> function retval = newfun(v)
      retval = 42*(v^23); 
  endfunction
  </code></pre>
  
  <p>Perhaps, it is just syntactic sugar, that is all, but still would be useful to know.</p>