Find peaks in data without using signal processing tool
120 views (last 30 days)
Show older comments
Harsimran Singh
on 8 Jul 2022
Commented: Harsimran Singh
on 11 Jul 2022
Hello Guys,
I am working on a set of data, attached.
I am using MatlabR2021b, I don't have signal processing tool. Therefore can't use peak function.
I need to find:
- Total number of peaks in data
- What are the corresponding values of eack peak
Would appreciate if anyone can suggest a solution.
Please let me know if my question is not clear.
Thanks
0 Comments
Accepted Answer
Star Strider
on 8 Jul 2022
The findpeaks function is in the Signal Processing Toolbox, and since you do not have access to it, use the core MATLAB islocalmax function instead (introduced in R2017b) —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1059360/peaktest.xlsx', 'VariableNamingRule','preserve');
Time = T1.Time;
spike2 = T1.spike2;
Lv = islocalmax(spike2, 'MinProminence',1); % Choose The Name-Value Pair Arguments To Return The Peaks You Want
TotalNrOfPeaks = nnz(Lv)
PeakTable = table(Time(Lv),spike2(Lv), 'VariableNames',{'Spike2Time','Spike2Amplitude'})
figure
plot(Time, spike2)
hold on
plot(Time(Lv), spike2(Lv), '^r')
hold off
grid
.
0 Comments
More Answers (1)
Sam Chak
on 8 Jul 2022
If the data is not too large, you can test features of the findpeaks() function in this forum.
[data] = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1059360/peaktest.xlsx');
plot(data.Time, data.spike2)
[pks, locs] = findpeaks(data.spike2)
num_of_pks = length(pks)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!