MATLAB: Assign an input to an anonymous function

anonymous function

Basically what I'm trying to do is ask the user to input a function of x 'f(x)' then assign it as an anonymous function then have the user input what x value they would like the function to be evaluated at…
This code isn't complete, but heres what I have so far with the output it gives me:
function [] = NewtsMeth
syms x
l=input('Please enter f(x) = ');
func=@(x) (l);
Xest=input('Pleae enter an initial guess = ');
k=func(Xest);
d=diff(func,x)
s=k
end
output:
>> NewtsMeth
Please enter f(x) = 6*x-8
Pleae enter an initial guess = 3
d =
6
s =
6*x - 8
Obviously this isn't Newton's method but I'm just trying to figure this input/evaluate part out.

Best Answer

I did it like this...
function []=test
syms x
digits(9);
func= input('Please enter f(x) = ');
Xest= input('Pleae enter an initial guess = ');
d=diff(func,x);
x=Xest;
for i = 0:15
ds=eval(d);
fs=eval(func);
x = x-((fs)./(ds));
vpa(x)
if x(i-1)==x(i)
break
end
end
end
Didn't end up using anonymous function.
The if loop is a little messed up beacuse I'm trying to find a way to break it once the answer repeats but I basically just changed x from symbolic and assigned the value of the guess to it then evaluated the function using "eval()"
I'm sure there's a better way to do it.