How to find x value for a given y?

21 views (last 30 days)
Yago Molano Gomez
Yago Molano Gomez on 8 Apr 2020
Answered: darova on 8 Apr 2020
I am trying to find the x value for a specific y value, from a fit. My first guess into how to solve this was:
xval = fzero([cfit - y], x0);
However this does not work as cfit do not recognize the - sign.
Is there a way to alter the coefficients of the fit I have? Alternatively, is there a simpler function that can be used?
Thanks in advance.

Answers (1)

darova
darova on 8 Apr 2020
Here is an example:
f = @(x) sin(x);
x = 0:10;
x0 = fzero(@(x)f(x)-0.5,pi);
plot(x0,f(x0),'or')
line(x,f(x))
If you have more parameters use thi
x0 = fzero(@(x)f(a,b,x)-0.5, pi);

Community Treasure Hunt

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

Start Hunting!