How to provide gaussian fitting of spectrums with multiple peaks ?
15 views (last 30 days)
Show older comments
Kiryl Zhaliazka
on 8 Oct 2021
Answered: Star Strider
on 8 Oct 2021
I have a plot of my Signal to wavenumber, and i want to saw can one pic containe several subpeks or not using gaussian fitting. could you help me find solution for this task?
0 Comments
Accepted Answer
Star Strider
on 8 Oct 2021
A version of that is actually provided in the findpeaks documentation (see Determine Peak Widths) and by getting all the outputs (see Peak Prominences) suitable initial parameter estimates for the widths.
The objective funciton could be something like this —
gausfit = @(b,x) b(1) .* exp(-(x-b(2)).^2/b(3));
x = linspace(0, 10)
y = gausfit([2,4,3],x) + randn(size(x))*0.5;
[B,fv] = fminsearch(@(b)norm(y-gausfit(b,x)), rand(3,1))
figure
plot(x, y, '.')
hold on
plot(x, gausfit(B,x), '-r')
hold off
grid
Use the peak locations, amplitudes, and widths, and use a for loop to fit each peak. Much depends on how well the peaks are defined in the data, so it may not be possible to fit all of them accurately.
.
0 Comments
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!