x is an n-dimensional vector, and f is a function which takes in n variables. Is there a way to dynamically evaluate f so that the number of variables does need to be pre-specified? For example, I would like a single piece of code where if n equal three, would give me f(x(1), x(2), x(3)), and if n = 4, would give me f(x(1), x(2), x(3), x(4)). Any help on this matter would be greatly appreciated.

# MATLAB: Arbitrary sized function evaluation

function handlevectorization

###### Related Question

- How to pass vectors as arguments for functions created using str2func
- Why it display Undefined variable for x when i hit run?(for the last line)
- Am I getting an error “vectors must be the same length”
- List values in symbolic function, a simplification problem
- I wanna make short code program (development)
- How to compose a function n-times and want value for a particular value of n
- Plotting f(x) as a function of x logistic map

## Best Answer