How to sum two gaussian curve fits (cfit) ?

5 ビュー (過去 30 日間)
Naif Alsalem
Naif Alsalem 2022 年 6 月 21 日
編集済み: Chris 2022 年 6 月 21 日
Dear All,
I have two peaks fitted with gaussian profiles (cfit) as shwon in the image below. I need to sum these two gaussian curves together but arthimetic operations are not allowed on cfit types in MATLAB. The peaks with the black and blue asterisks represent Row1 & Row2. The red curves are the gaussian fits performed as:
F1=fit (x1', y1','gauss2');
F2=fit (x2', y2','gauss2');
The summation of the F1 and F1 is just not allowed as:
D = F1+F2;
Undefined operator '+' for input arguments of type 'cfit'.
and I am looking for a way to add them together. Any thoughts?

採用された回答

Chris
Chris 2022 年 6 月 21 日
編集済み: Chris 2022 年 6 月 21 日
You could evaluate the fits and add them, though they would no longer be cfits.
x = linspace(20,35);
F1pts = feval(F1,x);
F2pts = feval(F2,x);
Fsum = F1pts+F2pts;
figure
plot(F1)
hold on
plot(F2)
plot(X,Fsum)
or more succinctly:
x = linspace(20,35);
plot(x, F1(x) + F2(x))
  1 件のコメント
Naif Alsalem
Naif Alsalem 2022 年 6 月 21 日
Thank you very much, @Chris. Absolutely what I needed. The keyword was with the: feval.
Much obliged

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by