Find peaks in data without using signal processing tool
조회 수: 140 (최근 30일)
이전 댓글 표시
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
채택된 답변
Star Strider
2022년 7월 8일
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
추가 답변 (1개)
Sam Chak
2022년 7월 8일
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)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!