mathematics – This bisection method code in matlab is giving me an error

I am coding how to get the exact root using the bisection method in MATLAB.
Dichotomie means bisection method.
p is the function, a0 and b0 are the 2 points, nmax is the maximum iterations and tolx is the error.

THIS IS THE BISECTION METHOD

function (r,n,errx) = Dichotomie(p,a0,b0,nmax,tolx)
%This function approximates the solution of p(x) using the method of
%dichotomie
i=1;
tx=10000000;
a(i) = a0;
b(i) = b0;
c(i) = (a0 + b0)/2;

while((i<=nmax) && (tx>tolx))   
    p=inline(p);  
    p=poly2sym(p);  

      if (p(a0) * p(c0)) < 0        
        a(i+1)=a(i);
        b(i+1)=c(i);
        c(i+1) = (a(i+1) + b(i+1)) / 2;
         tx=abs(c(i+1) - c(i));      
         i = i + 1;
     
      elseif (p(a0) * p(c0)) > 0
          a(i+1)=c(i);
          b(i+1)=b(i);
          c(i+1) = (a(i+1) + b(i+1)) / 2;
          tx=abs(c(i+1) - c(i));
          i = i + 1;
            
      elseif (p(a0) * p(c0)) == 0
          a(i+1) = a(i);
          b(i+1) = b(i);
          c(i+1) = (a(i+1) + b(i+1)) / 2;
          tx=abs(c(i+1) - c(i));
          i = i + 1;
     end

end  

r=c(i);  
n=i-1;  
errx=tx;    

THIS IS THE CALL OF MY CODE

clc;clear all;close all;  
%f(x) = x^2 +3*x - 1  
p=(1 3 -1);  
a0=1;  
b0=4;  
nmax=7;  
tolx=0.03563;  
(r,n,errx) = Dichotomie(p,a0,b0,nmax,tolx);  

AND IT’S GIVING ME THIS ERROR

Error using inline (line 50)  
Input must be a string.  

Error in Dichotomie (line 11)  
    p=inline(p);