MATLAB: I want to calculate a zero of a function, can anyone help me

functionspolynomials

as an example if we take x^3-8*x^2+17*x-10,i want to calculate this zero polynomial using dichotomy method but it does'nt give me the good result , can anyone help to solve this problem ?
clc
clear all
close all
syms x
f=input( 'donnez la fonction :' );
a=input( 'donnez la borne minimal de l intervalle :' );
c=input( 'donnez la borne maximal de l intervalle : ' );
b=(a+c)/2;
v=[];
n=[];
p=0;
for i=1:100
x(i)=(a(i)+b(i))/2;
if abs(f(x(i)))==0
v=[v,x(i)];
break
end
if (f(a(i))*f(x(i))<0)
a(i+1)=a(i);
b(i+1)=x(i);
else
b(i+1)=b(i);
a(i+1)=x(i);
end
end
for j=1:100
x(j)=(b(j)+c(j))/2;
if abs(f(x(j)))==0
n=[n,x(j)];
break
end
if (f(b(j))*f(x(j))<0)
b(j+1)=b(j);
c(j+1)=x(j);
else
c(j+1)=c(j);
b(j+1)=x(j);
end
end
p=[v,n]

Best Answer

https://de.mathworks.com/matlabcentral/fileexchange/33748-bisection-method?focused=5203297&tab=function
Best wishes
Torsten.