MATLAB: Evaluate Sym values

convertdoublesym

Hi, I trying to make a simple program, I would like to know how to make this
syms x; fun=x^2; x0=2;
x=x0; fun
And what a expect in the last line is 4 but I get X^2 How can I convert the sym to a double, I tried with doble(fun).
thank you

Best Answer

syms x;
fun=x^2;
x0=2;
subs(fun,x,x0)
double(ans)