Matlab has the good property that scalar functions (such as sin) can work on arrays, work with any element of the array, and return the array as a result.
I have a scalar function f(x,p), where xis the scalar, and pis the parameter (actually an array of parameters). Given a fixed parameter p, I want to run f(x,p)in an array A. In Ruby, it will look like this:
A.collect{|x| f(x,p)}
But I have no idea how to do this in Matlab for functions that take parameters, and not just the scalar from the array in which I want to work.
source
share