A combination of bisection and secant method

3 visualizzazioni (ultimi 30 giorni)
Kimberly Saleh
Kimberly Saleh il 19 Feb 2020
Commentato: Lavorizia Vaughn il 28 Set 2021
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

Risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by