What iteration method to use?

8 ビュー (過去 30 日間)
Teme
Teme 2018 年 3 月 2 日
コメント済み: Teme 2018 年 3 月 13 日
My problem is this:
I have a target value for x and I have to make an initial guess for y because it's unknown at the beginning. Then I make several calculations and finally get a calculated value for x. If my new x is not the same as the target value x I increase or decrease value y by certain small step and repeat all calculations until I find the solution for x.
I hope you get the idea without code. I tried doing this with while loop. It works but if my initial guess for y is far from the actual solution this may require lot's of iterations. My model will have several similar iterations loops so I wonder if there is more efficient iteration method available in Matlab? I'm new with Matlab and so far I haven't found the right tool for this.

採用された回答

John D'Errico
John D'Errico 2018 年 3 月 2 日
Why would you do this using a loop? You want to solve for the value of y, such that the value of
f(y)-x_target=0
Read the help and examples for fzero.
doc fzero
  1 件のコメント
Teme
Teme 2018 年 3 月 13 日
I don't want to use a loop, I want to use something like fzero :) That seems to be what I was looking for. Thanks!

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

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by