Borrar filtros
Borrar filtros

midpoint method iteration code error

3 visualizaciones (últimos 30 días)
Hanife Sahin
Hanife Sahin el 29 de Mzo. de 2022
Comentada: Hanife Sahin el 29 de Mzo. de 2022
Hi, how can i correct this code. It supposed to be a midpoint iteration but it keeps giving error. I've figured that its about exponential but I couldn't handle it. please help
f=inline('x^3-50*cos(x)-10*exp^(-0.50*x)','x');
x1=0;
x2=5;
e=0.000001;
while abs(x2-x1)>e
x3=(x1+x2)/2;
if(f(x1)*f(x3))>0
x1=x3
else x2=x3;
end
end
fprintf('x1=%.6f x2=%.6f\n',x1,x2);

Respuesta aceptada

Torsten
Torsten el 29 de Mzo. de 2022
f=inline('x^3-50*cos(x)-10*exp(-0.50*x)','x');
instead of
f=inline('x^3-50*cos(x)-10*exp^(-0.50*x)','x');
  1 comentario
Hanife Sahin
Hanife Sahin el 29 de Mzo. de 2022
Thank you so much it worked, I appreciate it!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by