A combination of bisection and secant method
3 views (last 30 days)
Show older comments
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 Comment
Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!