# how to find peaks for 100%,75%,50%,25% of the max peak

4 views (last 30 days)
Keshasni Earichappan on 2 Oct 2021
Edited: Kevin Holly on 4 Oct 2021
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';
x = M(:,1);
y = M(:,2);
tiledlayout('flow');
nexttile;
plot(x,y);
nexttile;
y2 = smoothdata(y);
plot(x,y2);
findpeaks(y2)
##### 2 CommentsShowHide 1 older comment
Keshasni Earichappan on 2 Oct 2021
attached data

Kevin Holly on 2 Oct 2021
Edited: Kevin Holly on 2 Oct 2021
I'm not entirely sure what peaks you are trying to identify. Below are techniques you can use.
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 CommentsShowHide 1 older comment
Kevin Holly on 4 Oct 2021
[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.

KSSV on 2 Oct 2021
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')