Signal peak integration (signal processing)
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I would like to integrate the peaks I have in this plot. I am looking for integrated the peak shown down below. I found a video of how I can do it in the origin software, but I am wondering if this is possible to do the same thing in matlab as well.
A few highlighted point in my plot is that is curve made by the data points are not smooth and also there are some broad peaks. An example file is attached. Thank you!
0 comentarios
Respuestas (1)
AH
el 20 de Oct. de 2022
Editada: AH
el 20 de Oct. de 2022
You may want to try something like below
%% Signal Model
t = linspace(0,1.5,1000);
mu = [1 5 9 13]/10; % position
amp = [3 2 3 1]; % amplitude
sigma = [2 3 6 4]/100; % width
x = 0;
for n = 1:length(mu)
x = x + amp(n)*exp(-((t - mu(n))/sigma(n)).^2);
end
figure, plot(t,x), xlabel('Time [sec]'), ylabel('Amp.'), grid("on")
%% Find Peaks
[pks,locs,w] = findpeaks(x,t,...
'Annotate','extents',...
'WidthReference','halfheight');
%% Plot Peak Area
figure
plot(t,x,'LineWidth',2), xlabel('Time [sec]'), ylabel('Amp.'), grid("on")
ylim([min(x)-0.5,max(x)+0.5])
hold("on")
for n = 1:length(pks)
tstart = locs(n)-w(n);
tend = locs(n)+w(n);
ind = sort(find((t >= tstart) & (t <= tend)));
pax = [t(ind(1)),t(ind(1)),t(ind(end)),t(ind(end))];
pay = [min(x([ind(1),ind(end)])) pks(n) pks(n) min(x([ind(1),ind(end)]))];
patch(pax,pay,'yellow','FaceAlpha',0.3)
end
We can play with the factors of the width to cover the desired area manually and approximate the Riemann integral using functions like sum or trapz for each of the highlighted area.
4 comentarios
Kevin Holly
el 28 de Oct. de 2022
You can make your own with App Designer. Here is a proof of concept for you. Intergrate AH's code in the App attached.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!