How to fit multiple peaks/dips
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a set a data where x-axis is the wavelength and y-axis is the intensity. It is seen from the attached image that there are many peaks/dips and it looks smooth. However, when it is zoomed, a lots of smaller peaks/dips is seen in the actual peak positions. I tried the following functions for the smoothness of the peaks.
(i) smooth: it does not help me so much
(ii) smoothdata: it smoothens so much that my results do not go with the theory
Could anyone please suggest me how to apply gaussian peak fitting/any other fittings for each of the peak?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/755999/image.jpeg)
2 comentarios
Star Strider
el 1 de Oct. de 2021
I am not certain what you want to do.
The approach I would take would be to do a Fourier transform (the fft function) of the time domain data, then analyse the results. It may be necessary to filter out the sine curve using the bandstop function in order to see the smaller details with reasonable accuracy. That should tell you enough about the data so that you can analyse the smaller peaks.
If you want to filter out the smaller peaks and keep the sine curve, use the bandpass function (essentially the opposite of the bandstop function) to filter out the noise.
.
Respuestas (2)
Image Analyst
el 1 de Oct. de 2021
See my code to fit multiple Gaussians. Change the number to the number you expect.
You should also look at findpeaks() to find and count the peaks, and sgloayfilt() to smooth the data.
2 comentarios
Image Analyst
el 1 de Oct. de 2021
For something that has peaks, you'd typically use an order of 2 or 3. A lower order (1) gives more smoothing while a higher order will allow the fitted polynomial to "hug" the actual signal more closely, giving less smoothing.
For the framelength You'd typically use at least about 5 or 7 elements. The more you use the more smoothing you get. For a signal such as yours you might want to use as many elements as you have in about a quarter or half of a cycle.
Just experiment around until it's smoothed the way you like it.
If the signal is known to be a noisy since wave, rather than a bunch of offset Gaussians, use frequency filtering to get the dominant cyclical signal, like Star said.
Star Strider
el 1 de Oct. de 2021
‘Thank you for your response. I would like to smooth the curve so that I get only one peak instead of mutiple smaller peaks. As you see when I zoomed one of the peaks, it shows many smaller peaks. However, I only want one good peak instead of these smaller peaks.’
My pleasure.
I am not certain what you intend by ‘one peak’ and ‘many small peaks’. There is no one peak in the time domain sine curve., instead several, one for each complete cycle
If you use the bandpass function to pass only the predominant frequency (of the sine curve) and eliminate everything else, you will get the one peak you want, at least in the frequency domain.
.
3 comentarios
Image Analyst
el 1 de Oct. de 2021
Attach your data if you need more help.
Star Strider
el 1 de Oct. de 2021
The easiest way to smooth the peak is to use the bandpass filter (preferably with the 'ImpulseResponse', 'iir' option) with the passband set so that it isolates the predominant sine signal and rejects the noise.
.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!