# Why the 'bisect' in my coding is undefined?

1 view (last 30 days)
Thirunaukkarasu Asogan on 27 Nov 2020
Commented: dpb on 27 Nov 2020
Hereby, this is my coding and the question is attached below.
Q=20;
g=9.81;
B=@(y)3+y;
Ac=@(y)3*y+y.^2/2;
func=@(y)(1-Q^2*B(y)./(g*Ac(y).^3));
xu=2.5;
xl=0.5;
es=0.01;
n_iter=10;
%%graphically
x=0.5:0.1:2.5;
plot(x,func(x),'r',x,0.*x,'b--');
%%numerically
[root1, f_1, e_1, n_1] = bisect(func,xl,xu,es,n_iter);
[root_2,f_2,e_2,n_2]=false_position(func,xl,xu,es,n_iter);
fprintf('Bisection method: \n');
fprintf('\t root:%g\n',root_1);
fprintf('\t function value at root:%g\n',f_1);
fprintf('\t approximate relative error:%g\n',e_1);
fprintf('\t number of iterations:%d\n\n',n_1);
fprintf('Bisection method: \n');
fprintf('\t root:%g\n',root_2);
fprintf('\t function value at root:%g\n',f_2);
fprintf('\t approximate relative error:%g\n',e_2);
fprintf('\t number of iterations:%d\n\n',n_2);

John D'Errico on 27 Nov 2020
Then it looks as if you have not defined a function named bisect, but a script file. Time to learn what a function is and how to write one?
Thirunaukkarasu Asogan on 27 Nov 2020
yes maybe you can assist me with that.
dpb on 27 Nov 2020
Start by typing
doc function