Borrar filtros
Borrar filtros

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

10 visualizaciones (últimos 30 días)
Keshasni Earichappan
Keshasni Earichappan el 2 de Oct. de 2021
Editada: Kevin Holly el 4 de Oct. de 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';
M = readmatrix(f);
x = M(:,1);
y = M(:,2);
tiledlayout('flow');
nexttile;
plot(x,y);
nexttile;
y2 = smoothdata(y);
plot(x,y2);
findpeaks(y2)

Respuesta aceptada

Kevin Holly
Kevin Holly el 2 de Oct. de 2021
Editada: Kevin Holly el 2 de Oct. de 2021
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 comentarios
Keshasni Earichappan
Keshasni Earichappan el 4 de Oct. de 2021
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 el 4 de Oct. de 2021
Editada: Kevin Holly el 4 de Oct. de 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.

Iniciar sesión para comentar.

Más respuestas (1)

KSSV
KSSV el 2 de Oct. de 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')

Categorías

Más información sobre Spectral Estimation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by