A combination of bisection and secant method

2 ビュー (過去 30 日間)
Kimberly Saleh
Kimberly Saleh 2020 年 2 月 19 日
コメント済み: Lavorizia Vaughn 2021 年 9 月 28 日
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 件のコメント
Lavorizia Vaughn
Lavorizia Vaughn 2021 年 9 月 28 日
I think you just need to out parents around the p in function p

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by