fzero use with offset

4 ビュー (過去 30 日間)
Simon Kreibich
Simon Kreibich 2016 年 1 月 25 日
コメント済み: Simon Kreibich 2016 年 1 月 25 日
Hi,
is it possible to make an offset with fzero?
I have a function where I found the root with fzero. Now I want to use the same function but with an offset and let fzero compute the root of the function + offset.
Is this possible somehow?
Thank you for your help.
  1 件のコメント
Torsten
Torsten 2016 年 1 月 25 日
Define a new function to be your old function plus the offset and call fzero again with this new function.
Best wishes
Torsten.

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

採用された回答

Stephen23
Stephen23 2016 年 1 月 25 日
編集済み: Stephen23 2016 年 1 月 25 日
>> fun = @(x) x^2;
>> ofs = 3;
>> z = fzero(@(x)fun(x)-ofs,1)
z = 1.7321
and confirm that the function value is (almost) zero:
>> fun(z)-ofs
ans = -3.9968e-015
>> fun(z)
ans = 3.0000
  1 件のコメント
Simon Kreibich
Simon Kreibich 2016 年 1 月 25 日
Oh, I thought I need to add the offset via an option.
Thank you, I solved my problem! Just that simple..

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by