bisection iteration wither different values than 0

How to solv the eq f(y)=0.2? instead of f(y)=0.
d=0.250; % I SUPPOSED d=1.3
f=@(y) 0.46-0.5*cos(3.14*(y/d))+0.004*cos(2*3.14*(y/d))
format long
eps_abs = 1e-5;
eps_step = 1e-5;
a = 0; % Initial Guess to your function such that f(a)>0.
b = 1; % Initial Guess to your function such that f(b)<0.
while (b - a >= eps_step || ( abs( f(a) ) >= eps_abs && abs( f(b) ) >= eps_abs ) )
c = (a + b)/2;
if ( f(c) == 0 )
break;
elseif ( f(a)*f(c) < 0 )
b = c;
else
a = c;
end
end

 채택된 답변

Walter Roberson
Walter Roberson 2013년 3월 10일

0 개 추천

To solve f(y) = 0.2, define f1(y) = f(y) - 0.2, and then solve for f1(y) = 0.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by