I came into matrix world from loop world (C, etc)
I would like to call a function on each individual member of a vector/matrix, and return the resulting vector/matri
The function should look like this:
function retval = gauss(v, a, b, c)
retval = a*exp(-(v-b).^2/(2*c^2));
I would recommend you to read MATLAB documentation on how to vectorize the code and avoid loops:
Code Vectorization Guide
Techniques for Improving Performance
Also remember that sometime code with loops can be more clear that vectorized one, and with recent introduction of JIT compiler MATLAB deals with loops pretty well.