fzero use with offset

3 views (last 30 days)
Simon Kreibich
Simon Kreibich on 25 Jan 2016
Commented: Simon Kreibich on 25 Jan 2016
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 Comment
Torsten
Torsten on 25 Jan 2016
Define a new function to be your old function plus the offset and call fzero again with this new function.
Best wishes
Torsten.

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 25 Jan 2016
Edited: Stephen23 on 25 Jan 2016
>> 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 Comment
Simon Kreibich
Simon Kreibich on 25 Jan 2016
Oh, I thought I need to add the offset via an option.
Thank you, I solved my problem! Just that simple..

Sign in to comment.

More Answers (0)

Categories

Find more on Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!