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 ExchangeNumerical 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