This looks really simple. I want to define a function:
syms x
f = x^2
I want to be able to do f(4) and it spits out 16. I also want to avoid having to write a new m-file.
When dealing with symbolic variables, to substitute in a numeric value, use subs(), i.e. symbolic substitution:
syms x
f = x^2
subs(f,4)
>> f = @(x) x^2;
>> f(4)
ans =
16
x in the function handle is NOT the symbolic x you defined.( ). The name itself can be anything and it will not match base workspace variables since each function has it's own workspace when called.