How do find the peaks of pulses from an array
4 views (last 30 days)
Show older comments
I have an array that is about 1million x 2 I need help finding the peaks of each pulse of the entire data. Any ideas?
The data set is here below could any one give me an example of getting a peak for each Pulse throughout the entire data set?
0 Comments
Accepted Answer
Star Strider
on 20 May 2021
It would be helpful to have a sample of the data.
9 Comments
Star Strider
on 21 May 2021
Edited: Star Strider
on 21 May 2021
As always, my pleasure!
I thought about one way of ‘clustering’ it, that being to threshold either the upper peak of the envelope or both the upper and lower peaks.
Try this —
LD = load('Sig_2_Bucket_Flicking_1_106_Dogbone_9mm_5_6_2021_Xaxis_Tailored_Data2.mat');
data_seg = LD.data_seg;
[ds_envu,ds_envl] = envelope(data_seg(:,2), 150, 'peak');
[pksu,locsu] = findpeaks(ds_envu, 'MinPeakProminence',10);
[pksl,locsl] = findpeaks(-ds_envl, 'MinPeakProminence',10);
ix = ds_envu > 20; % Envelope Above Threshold
dix1 = strfind(ix', [0 1]); % Leading Edge
dix0 = [strfind(ix', [1 0]) numel(ix)]; % Trailing Edge
EdgMtx = [dix1; dix0]; % Matrix Of Leading & Trailing Edges
figure
plot(data_seg(:,1), data_seg(:,2))
hold on
plot(data_seg(:,1), ds_envu, '-r')
plot(data_seg(locsu,1), ds_envu(locsu), '^g', 'MarkerFaceColor','g')
plot(data_seg(:,1), ds_envl, '-m')
plot(data_seg(locsl,1), ds_envl(locsl), 'vc', 'MarkerFaceColor','c')
for k = 1:size(EdgMtx,2)
idxrng = EdgMtx(1,k):EdgMtx(2,k);
text(data_seg(fix(median(idxrng)),1), ds_envu(fix(median(idxrng))), sprintf('Max = %6.1f, Min = %6.1f',max(ds_envu(fix(median(idxrng)))), min(ds_envl(fix(median(idxrng))))), 'Vert','middle', 'Horiz','left', 'Rotation',90)
end
hold off
grid
legend('Data','Upper Envelope','Upper Envelope Peaks','Lower Envelope','Lower Envelope Peaks', 'Location','best')
Fg = gcf;
pos = Fg.Position;
Fg.Position = pos+[-200 -500 800 500];
It defines the peak clusters, determins the maximum and minimum of each, and returns both. That shoul do essentially everything necessary, except for a few tweaks to deliver the desired information in the desired format.
EDIT — (21 May 2021 at 21:15)
Added plot figure —

.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!