How to label your peaks in descending order?

2 ビュー (過去 30 日間)
John Mark Enhaynes
John Mark Enhaynes 2021 年 3 月 30 日
編集済み: LO 2021 年 3 月 30 日
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 件のコメント
John Mark Enhaynes
John Mark Enhaynes 2021 年 3 月 30 日
I've tried that, but I've got similar errors from other users I've seen in the forum
Mathieu NOE
Mathieu NOE 2021 年 3 月 30 日
I ve plenty of other similar functions (attached)
try with peakseek and do the sorting by yourself afterwards

サインインしてコメントする。

採用された回答

LO
LO 2021 年 3 月 30 日
編集済み: LO 2021 年 3 月 30 日
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)
scatter(locs(order),peaks(order),'rv');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by