A combination of bisection and secant method
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello! So I have to write a program on Matlab using both the bisection and secant method in one. I'm super new to Matlab and this is the code I managed to figure out. The program tells me that when I call a function, I have to use parentheses. But I don't see where I should put that. I've also attached the required steps for the program. Thank you!
function p = bisection(f, a, b, tol)
w=1;
for i=1:100
p= a +(w*f(a)*(a-b)/f(b)-w*f(a));
fprintf(a,b,p,f(p));
if f(p)*f(b)>0
w=0.5;
else
w=1;
a=b;
end
b=p;
if abs(b-a)<tol || abs(f(p))<tol
break;
end
end
1 comentario
Lavorizia Vaughn
el 28 de Sept. de 2021
I think you just need to out parents around the p in function p
Respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown 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!