How to fit n gaussians/peaks

15 views (last 30 days)
Knut Tutgut
Knut Tutgut on 7 Oct 2015
Commented: Knut Tutgut on 8 Oct 2015
Hi! I need to fit Gaussian like curves with up to 100 peaks. So far, for less than 8 peaks, I have been using the matlab curve fitting tool box and its gaussian fit algorithm, but it seems like you can only fit 8 gaussians at the most to your curve. Is there a simple way or another function to fit about 100 peaks?
Thanks a lot knut
  5 Comments
Image Analyst
Image Analyst on 8 Oct 2015
If you don't have the stats toolbox, and if you can post your data, I can try fitgmdist() on it to see if it works.
Knut Tutgut
Knut Tutgut on 8 Oct 2015
That actually seems to work quite well! If it's too complex after all, I will get back to your offer!

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 7 Oct 2015
How about if you locate each peak with findpeaks(), then at each peak location, "fall down" the slopes on each side and extract just that one peak? Then fit that peak to a Gaussian. Repeat for all peaks found.
  2 Comments
Knut Tutgut
Knut Tutgut on 7 Oct 2015
Edited: Knut Tutgut on 7 Oct 2015
So in principle, that would mean splitting the data into n parts (where n is the number of peaks) and fit single gaussians to each part, respectively, right? Shouldn't there exist some way to first fit the curve and the use findpeaks() on the fit? I would assume that other people have written such function to fit multiple peaks? I couldn't really find anything like that on the internet though.. :( Thanks for your help!
Image Analyst
Image Analyst on 7 Oct 2015
Well if you have the Statistics and Machine Learning Toolbox, you can try using
GMModel = fitgmdist(X, 100)
to use a Gaussian Mixture Model, though I don't know how well it will handle 100 ill-defined peaks.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!