Fitting data with two peaks

48 ビュー (過去 30 日間)
Niles Martinsen
Niles Martinsen 2012 年 6 月 4 日
編集済み: John Kelly 2015 年 3 月 2 日
Hi
I have some data, which is not too different from the top graph in this picture: <http://www.aanda.org/index.php?option=com_image&format=raw&url=/articles/aa/full/2004/12/aa0526/img14.gif>
In other words, there are two peaks that each represent a Lorentzian. I am not sure how to fit this in MatLAB. Is there a way to fit the data to one function consisting of two Lorentzians, or do I have to split the data set in two, one peak in each?
Ultimately I need to find the x-position of each peak.
Best, Niles.
  1 件のコメント
Enrique
Enrique 2014 年 7 月 30 日
Niles,
Did you ever figure out how to do this and/or implement any of the solutions suggested below? I am trying to fit two Lorentzians to similar Raman data as yours (is yours a graphene Raman spectrum as well?). In the past I have done this using a single Lorentzian fitting function I found ( Lorentzian Function Fit lorentzfit), but have not tried to implement two Lorentzians. Any suggestion would help a lot.
Thanks,
Enrique

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

回答 (5 件)

Geoff
Geoff 2012 年 6 月 4 日
Define a function that accepts the parameters of the two lorenzian curves and computes the full curve.
I don't know how many parameters you need cos I'm no mathematician =) Let's say 2?
dualLorentz = @(x, a1, b1, a2, b2) = lorenz(x, a1, b1) + lorenz(x, a2, b2);
Then, define a function to generate that curve, subtract your actual dataset, square the result and sum it.... While you're at it, parameterise the whole thing (ie a vector p of [a1, b1, a2, b2])
objFn = @(p, x, y) sum( (y - dualLorentz(x, p(1), p(2), p(3), p(4))) .^ 2 );
Then chuck it at fsolve or fminsearch - assuming your dataset is in X and Y:
p0 = % some initial guess at a1, a2, b1, b2 : you can probably be very basic
p = fsolve( @(p) objFn(p, X, Y), p0 );

Image Analyst
Image Analyst 2012 年 6 月 4 日

Ryan
Ryan 2012 年 6 月 4 日
編集済み: John Kelly 2015 年 3 月 2 日
You could get a close approximation of peak position with a cubic spline fit and local maxima. You could also try just smoothing the data first as well and then finding the maxima.
Cubic Spline:

Frederic Moisy
Frederic Moisy 2012 年 6 月 7 日
Hi, you can try the Ezyfit toolbox:
In particular, there is an example with two peaks (here fitted with the sum of 2 gaussian curves):

Niles Martinsen
Niles Martinsen 2012 年 6 月 7 日
If I use this approach http://www.mathworks.se/support/solutions/en/data/1-GNRWCU/index.html, is there a way to obtain the errors on the fitted parameters?

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by