How to provide gaussian fitting of spectrums with multiple peaks ?

2 views (last 30 days)
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?

Accepted Answer

Star Strider
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)
x = 1×100
0 0.1010 0.2020 0.3030 0.4040 0.5051 0.6061 0.7071 0.8081 0.9091 1.0101 1.1111 1.2121 1.3131 1.4141 1.5152 1.6162 1.7172 1.8182 1.9192 2.0202 2.1212 2.2222 2.3232 2.4242 2.5253 2.6263 2.7273 2.8283 2.9293
y = gausfit([2,4,3],x) + randn(size(x))*0.5;
[B,fv] = fminsearch(@(b)norm(y-gausfit(b,x)), rand(3,1))
B = 3×1
2.1229 4.1009 3.7021
fv = 4.8977
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.
.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by