# How can I find X for given Y value in a fitted curve?

147 views (last 30 days)

Show older comments

Pablo Martínez Filgueira
on 3 Mar 2015

Edited: Christy Zheng
on 17 May 2020

Hi everyone.

I would like to know how to find the X value of a fitted curve given an Y value.

I had some data and fitted them using Gaussian fit. Now they look like this in my workspace:

An example of these functions as seen in the Command Window is:

f50 =

General model Gauss1:

f50(x) = a1*exp(-((x-b1)/c1)^2)

Coefficients (with 95% confidence bounds):

a1 = 7.81 (7.602, 8.018)

b1 = 1.497e-013 (-0.001774, 0.001774)

c1 = 0.08174 (0.07924, 0.08425)

Does someone wonder how to do it?

I really appreciate any help you can provide.

Pablo

##### 0 Comments

### Accepted Answer

Torsten
on 3 Mar 2015

Use the inverse function:

X=b1+c1*(log(a1./Y))^0.5

or

X=b1-c1*(log(a1./Y))^0.5

Best wishes

Torsten.

### More Answers (2)

Andrei Bobrov
on 3 Mar 2015

other variant

X = arrayfun(@(y)fzero(f50(x)-y,1),Y);

##### 3 Comments

Christy Zheng
on 17 May 2020

Edited: Christy Zheng
on 17 May 2020

Ingrid
on 3 Mar 2015

you can do this with the function

Y = feval(cfit,X);

which you could have easily found yourselve if you would have typed

doc cfit

### See Also

### Categories

### Products

### Community Treasure Hunt

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

Start Hunting!