How to label your peaks in descending order?
2 views (last 30 days)
I search the whole community and website on how to label my peaks from 1-5 from the highest value given
Here is my code I've made so far:
fid=fopen('Programming 2 Data.txt');
x = f(:,1);
y = f(:,2);
I have search the terminology on findpeaks, but it doesn't really help me that much to get the desired result that I wanted.
LO on 30 Mar 2021
Edited: LO on 30 Mar 2021
something like this ?
my guess is that you won't need the sortedX because you are looking for peaks on your Y axis, right ? But try adapting this to your code. Eventually the "locs" variable will have to be modified taking into account your X vector.
[peaks,locs,widths] = findpeaks(sortedY,'MinPeakHeight',290,'Annotate','Extents');
[vals,order] = sortrows(peaks,'descend'); % sort them based on peak value, for instance, but you can sort them based on widths as well (just replace peaks with widths in sortrows)