Undefined function or variable 'bisection'.

12 visualizaciones (últimos 30 días)
Brian Reinhard
Brian Reinhard el 15 de Mzo. de 2021
Editada: James Tursa el 15 de Mzo. de 2021
function [x,e] = mybisect (f,a,b,n)
c = f(a);
z = f(b);
if (f(a)*f(b) > 0)
error ('Function has ame sign at both endpoints')
end
disp(' x y')
for i = 1:n
x = (a+b)/2;
y = f(x);
disp([ x y])
if y == 0.0
a = x;
b = x;
break
end
if c.y < 0.0
b = x;
else
a = x;
end
end
x = (a+b)/2;
e = (b-a)/2;
end
  1 comentario
Brian Reinhard
Brian Reinhard el 15 de Mzo. de 2021
when i use:
>> f=inline('@(x) cos*x+sin*x','x');
>> akar=bisection(f,2,4,20,1e-2)
it will show:
Undefined function or variable 'bisection'.
Pls someone can tell me where is the problem?

Iniciar sesión para comentar.

Respuestas (1)

James Tursa
James Tursa el 15 de Mzo. de 2021
Editada: James Tursa el 15 de Mzo. de 2021
From the error message, it looks like you are calling the function using the name "bisection", but the actual name of the function is "mybisect". Hence the error.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by