how to find peaks for 100%,75%,50%,25% of the max peak
10 次查看(过去 30 天)
显示 更早的评论
Hi good day.. i am having trouble in identify the 100%,75%,50%,25% of the peaks of my data(only need to identify 4 peaks).Hope anyone can help me to solve the problem.Thank you in advance
- VINCENT NORMALISED MC.txt
f = 'file:///C:/Users/user/Documents/VINCENT%20NORMALISED%20MC.txt';
M = readmatrix(f);
x = M(:,1);
y = M(:,2);
tiledlayout('flow');
nexttile;
plot(x,y);
nexttile;
y2 = smoothdata(y);
plot(x,y2);
findpeaks(y2)
采纳的回答
Kevin Holly
2021-10-2
编辑:Kevin Holly
2021-10-2
I'm not entirely sure what peaks you are trying to identify. Below are techniques you can use.
You can add labels to your peaks to help you identify them. You can also set a minimum peak prominence.
findpeaks(y2,'MinPeakProminence',4) % adds peak labels to graph
[pks,locs,w,p] = findpeaks(y2,'MinPeakProminence',4) %obtains informations about peaks
text(locs+.02,pks,num2str((1:numel(pks))')) % place text next to labels
From the labels, it is clear the top four peaks in value with the settings above are 4, 6,17, and 21.
top4peaks = [4 6 17 21];
nexttile;
plot(x,y2);
findpeaks(y2,'MinPeakProminence',4)
text(locs(top4peaks)+.02,pks(top4peaks),num2str(top4peaks'))
[pks(top4peaks),locs(top4peaks),w(top4peaks),p(top4peaks)]
nexttile;
plot(x,y2);
findpeaks(y2,'MinPeakProminence',40)
Edit: I just saw in title that you want 100%,75%,50%,25% of the max peak
Find max peak with this command
[value index] = max(pks)
75%, 50%, and 25%
pks(abs(pks-.75*value)==min(abs(pks-.75*value)))
pks(abs(pks-.50*value)==min(abs(pks-.50*value)))
pks(abs(pks-.25*value)==min(abs(pks-.25*value)))
2 个评论
Kevin Holly
2021-10-4
编辑:Kevin Holly
2021-10-4
[value, index] = max(pks);
"value" returns the maximum value the the array, "pks".
"index" returns the index into the operating dimension that corresponds to the maximum value of "pks" for any of the previous syntaxes.
更多回答(1 个)
KSSV
2021-10-2
T = readtable('VINCENT NORMALISED MC.txt') ;
x= T.(1) ; y = T.(2) ;
% find max
[val,idx] = max(y) ;
% find 75, 50 and 25 of max
vals = val*[75 50 25]/100 ;
idx = knnsearch(y,vals') ;
plot(x,y)
hold on
plot(x(idx),y(idx),'*r')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Estimation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!