All optimization solvers require that the objective function return a scalar value. You need to write your objective function in a way that it returns a scalar, not a vector or an array.
If you are trying to solve for a variety of parameter values, well, you will have to write a loop and solve for one parameter value at a time.
Alan Weiss
MATLAB mathematical toolbox documentation