MATLAB: ??? Error using ==> inline.subsref at 14 Not enough inputs to inline function.

secant method

Hi everyone,
I'm trying to make a program that finds the roots of a function using the Secant method for a class project. In class we only use very simple Matlab commands so most of the stuff I found online was way over-complicated for me to understand and use.
So what's happening is I'm getting an error:
??? Error using ==> inline.subsref at 14
Not enough inputs to inline function.
Error in ==> secante at 9 z=b-((fx(b)*(b-a))/(fx(b)-fx(a)));
when running secante(0,2,0.000001) for the function (e^(-0.5*x))*(cos(3*x))-e^(-x)
If anyone can help me understand why this is happening and check if I'm making any other mistakes it would be deeply appreciated. Here's my code:
function R = secante(a,b,erro)
f=input('Inserir f(x)= ','s');
fx = inline(f);
e=(abs(b-a))/(abs(b));
n=3;
R(1)=a;
R(2)=b;
while (erro<e)
z=b-((fx(b)*(b-a))/(fx(b)-fx(a)));
a=b;
b=z;
e=((abs(b-a))/(abs(b)));
R(n)=z;
n=n+1;
end

Best Answer

MATLAB does not know the constant "e" and so thinks it is a variable. The user needs to enter
exp(-0.5*x)*cos(3*x)-exp(-x)