MATLAB: Can’t a variable holding an equation be used to make a function handle

functionhandlesMATLAB

%% Test
syms x
eqn(x) = x^2
func = @(x) eqn
func(2)

Best Answer

I would simply use matlabFunction() as sir Walter says but maybe you have the follwing in mind:
func = @(x) eqn(x)