How can I solve a function for x given y?

I am trying to solve the following Weibull function for x given y.
f=fit(edges, binMean, 'Weibull', 'StartPoint', [0.01, 2]);
Obviously it's easy to solve for y given x.
y=f(0.77)
But how can I do the reverse? I want to know x when y is 0.77.

 Accepted Answer

x=fzero(@(x) f(x)-y, 0.5 )

4 Comments

Thanks Matt. Just tried this as
x=fzero(@(x) f(x)-0.77, 0.5 )
but it gave me 0.6332
This doesn't appear to work as the correct value is about 0.07.
The equation curves downwards later and 0.6332 is another root.
Give a different starting guess, such as
x=fzero(@(x) f(x)-0.77, 0.1 )
Ahhh makes sense! That did it! THANK YOU!
Or give the interval of interest for x, e.g.,
x=fzero(@(x) f(x)-0.77, [0,0.25])

Sign in to comment.

More Answers (0)

Asked:

on 8 Oct 2020

Commented:

on 8 Oct 2020

Community Treasure Hunt

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

Start Hunting!