現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
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) ?
2 ビュー (過去 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
Ameer Hamza
2018 年 4 月 30 日
My code does gives you an estimate of the F function, and its inverse G.
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)