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

조회 수: 12 (최근 30일)
Keshasni Earichappan
Keshasni Earichappan 2021년 10월 2일
편집: Kevin Holly 2021년 10월 4일
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
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
Keshasni Earichappan
Keshasni Earichappan 2021년 10월 4일
hi @Kevin Holly..thanks for the answer...I'm confused with your code as i mentioned below...what is the value index :)
[value index] = max(pks);
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)))
Kevin Holly
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
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')

카테고리

Help CenterFile Exchange에서 Spectral Estimation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by