I want to fit some data x and y to a specific equation f(x) and then estimate this fitted data as g(x)=1/f(x) ?
1 次查看(过去 30 天)
显示 更早的评论
j.D
2018-4-30
x=[0,0.5,1,1.5,2,2.5];
y=[1,0.8,0.6,0.4,0.2,0];
F(x)= exp[(a*x^2)+(b*x)+c], where a,b,c are not known to me
after fitting this data to this equation i want to get g(x)=1/f(x). The picture attached below demonstrates what we are trying to do. Figure A shows x and y fitted to f(x) and figure B shows estimated g(x)=1/f(x).
采纳的回答
Ameer Hamza
2018-4-30
fitFunction = fittype('exp(a*x.^2+b*x+c)');
coff = fit(x', y', fitFunction);
a = coff.a;
b = coff.b;
c = coff.c;
18 个评论
Walter Roberson
2018-4-30
Once you have the coefficients you can construct f(x) with a simple anonymous function and then define g = @(x)1./f(x)
j.D
2018-4-30
编辑:Walter Roberson
2018-4-30
Thanks for your guidance after your comments this is what i am doing but still getting some error, please guide
fitFunction = fittype('exp(a*x.^2+b*x+c)');
x=[0,0.5,1,1.5,2,2.5];
y=[1,0.8,0.6,0.4,0.2,0];
coff = fit(x', y', fitFunction);
a = coff.a;
b = coff.b;
c = coff.c;
Z=exp(-0.3365*x.^2-0.1660*x+-0.0150);
F=exp(a*x.^2+b*x+c);
G(x)= Z/F;
Walter Roberson
2018-4-30
Z = @(x) exp(-0.3365*x.^2-0.1660*x+-0.0150);
F = @(x) exp(a*x.^2+b*x+c);
G = @(x) Z(x)./F(x);
fplot(G, [x(1), x(end)])
Ameer Hamza
2018-4-30
编辑:Ameer Hamza
2018-4-30
F = exp(-0.3365*x.^2-0.1660*x+(-0.0150))
is actually the result of curve fitting. I think OP is trying to take the inverse of F but forgot to include @(x) sign.
@j.D please use this line exactly as given below,
F = @(x) exp(a*x.^2 + b*x + c);
G = @(x) 1./F(x);
Walter Roberson
2018-4-30
Ameer Hamza: if you look at the sample calibration function, it is pretty linear. We might suspect that something that is pretty close to 1:1 is expected.
For example it could be the situation that the model was defined at being exactly exp(-0.3365*x.^2-0.1660*x+-0.0150), but that actual data is then obtained, and a correction function needs to be calculated based upon the data.
j.D
2018-4-30
Thanks guys for your help, both the approaches are good but ameer hamza anwser suits my scenario, thanks again walter and ameer hamza
j.D
2018-4-30
Walter you might be right but in your case I am not getting the inverse of data can i some how get invert of it with your logic ?
Ameer Hamza
2018-4-30
@j.D, Walter equation does not invert the data. He was mentioning that you might want to compare the estimated model with an actual model which you already know. If all you want is value of f and g, then the equation i wrote will be sufficient for you.
Ameer Hamza
2018-4-30
@j.D's comment from answer moved here
Thanks ameer..can you tell me does your code not give me the estimated calibration function ?and thanks for sharing your knowledge with me
Walter Roberson
2018-4-30
Z = @(x) exp(-0.3365*x.^2-0.1660*x+-0.0150);
F = @(x) exp(a*x.^2+b*x+c);
recipF = @(x) 1./F(x);
G = @(x) Z(x) .* recipF(x);
fplot(G, [x(1), x(end)])
This is based upon your earlier definition
G(x)= Z/F;
but breaks out the 1/F step that you had asked for originally.
We cannot tell whether your estimated calibration function for your purposes is the 1/F or is the Z/F .
Walter Roberson
2018-5-1
Flimg = double(YourMatrix) ;
Out = cast(Flimg.*G(Flimg), class(YourMatrix)) ;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)