An example of a function that takes another function as an argument. function r = vectoreval(f,x); N = length(x); r = zeros(N,1); for i=1:N r(i) = f(x(i)); end end You can call this function in Matlab with the syntax x = linspace(0,pi,100); s = vectoreval(@sin, x);