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

11 次查看(过去 30 天)
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

采纳的回答

Torsten
Torsten 2015-3-3
Use the inverse function:
X=b1+c1*(log(a1./Y))^0.5
or
X=b1-c1*(log(a1./Y))^0.5
Best wishes
Torsten.
  1 个评论
Pablo Martínez Filgueira
Thank you! It is a good proposal but I have many fits and I have to find a quick way to do it.
Good answer anyway ;)

请先登录,再进行评论。

更多回答(2 个)

Andrei Bobrov
Andrei Bobrov 2015-3-3
other variant
X = arrayfun(@(y)fzero(f50(x)-y,1),Y);
  3 个评论
Pen-Li (Ben) Yu
Pen-Li (Ben) Yu 2018-7-12
Below is my modification to Andrei's solution:
X = arrayfun(@(y)fzero(@(x)f50(x)-y,x0),Y)
x0 is the initial value for the fzero function Y can be a scalar or a vector
Christy Zheng
Christy Zheng 2020-5-17
编辑:Christy Zheng 2020-5-17
I'm sorry for my lack of understanding, but to clarify X is the value you are looking for given a Y on the fitted curve. What are x and y referring to?

请先登录,再进行评论。


Ingrid
Ingrid 2015-3-3
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
  3 个评论
Ingrid
Ingrid 2015-3-3
I have read your question but overlooked the fact that you were looking for the X values and not the Y values
in this case you might find this link helpful:
Pablo Martínez Filgueira
thanks, but during the 2 hours before asking this question I also found that topic.
see you

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by