How to label your peaks in descending order?
Show older comments
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');
e=textscan(fid,'%f %f','headerlines',1);
f=cell2mat(e);
x = f(:,1);
y = f(:,2);
[sortedX,sortIndex]=sort(x);
sortedY=y(sortIndex);
plot(x,y)
findpeaks(sortedY,sortedX,'MinPeakHeight',290,'Annotate','Extents');
xlabel('cm^-1')
ylabel('%T')
title('FTIR')
axis tight
grid
set(gca,'xdir','reverse')
I have search the terminology on findpeaks, but it doesn't really help me that much to get the desired result that I wanted.
3 Comments
Mathieu NOE
on 30 Mar 2021
hello
you can use findpeaks with sorting : exmple => Sort the peaks from tallest to shortest.
[psor,lsor] = findpeaks(PeakSig,x,'SortStr','descend');
John Mark Enhaynes
on 30 Mar 2021
Mathieu NOE
on 30 Mar 2021
I ve plenty of other similar functions (attached)
try with peakseek and do the sorting by yourself afterwards
Accepted Answer
More Answers (0)
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!