Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Best method to be implimented

1 回表示 (過去 30 日間)
Dimitrios
Dimitrios 2014 年 9 月 17 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Having a couple of equations inside a function. This function has an output.This output is again an input in the same equation until the tolerence between the tolerence between last output and previous output have a certain value like 10e-4. This could be implimented with a while loop. Something like this i guess (still I didnt impliment it in MATLAB) :
y = 1
x= = fun(y)
while (y-x)>10e-4
y=x
x = fun(y)
end
Is there any other way?
  1 件のコメント
Guillaume
Guillaume 2014 年 9 月 17 日
The code you've shown will do what you've described and is probably the simplest.
The issue with your code and what you've described is that it may never converge (e.g. if fun(x) = -x), so rather what don't you say what you're trying to achieve.

回答 (1 件)

Matt J
Matt J 2014 年 9 月 17 日
If fun(x) is continuous wrt x and the iterations you describe do converge to something, then the limit will satisfy
x=fun(x)
which you can solve with fzero
fzero(@(x) x-fun(x), x0)

Community Treasure Hunt

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

Start Hunting!

Translated by