how to find peaks for 100%,75%,50%,25% of the max peak
10 ビュー (過去 30 日間)
古いコメントを表示
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
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 件のコメント
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
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')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spectral Estimation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!