When I run the following Matlab code:
x=sym('x',[2 1])
func=x.'*x
f=matlabFunction(func)
x=rand(2,1)
f(x(1),x(2)) % this works
f(x) % but this gives an error
I get an error:
Error using symengine>makeFhandle/@(x1,x2)x1.^2+x2.^2
Not enough input arguments.
I want to make the code more general for an n-vector, with n determined in the code.
Therefore I cannot list all n variables like f(x(1), x(2), ..., x(n))
Is there a way to convert the n-vector into a list of n components to be passed to the function?