MATLAB: Can we convert symbolic result to function handle with vector input

MATLABsymbolic to function handles

I have a symbolic result with the form of f(a1,a2,a3)=0. Now I need to convert it as f=@(x)(x(1),x(2),x(3)) to fit some built-in solvers. Is there any way to do this? By the way, I know by using "matlabFunction" we can convert it as f=@(a1,a2,a3). Thanks.

Best Answer

I you used matlabFunction, and you already have it as ‘f=@(a1,a2,a3)’, then you sort of answered your own Question.
For example:
f = @(a1,a2,a3) a1 + 2.*a2 - a3;
g = @(x) f(x(1),x(2),x(3));
Q = g([2,3,5])
Q =
3