How to find common peak and save it location

1 回表示 (過去 30 日間)
Phudit Kanittasut
Phudit Kanittasut 2021 年 4 月 7 日
コメント済み: Mathieu NOE 2021 年 4 月 8 日
How can I fine common peak? Ex. When I have 2 data that data 1 have peak at X axis location at 3 ,4 ,5 ,6 ,7 and data 2 at 1 , 4 ,6 , 8 ,10 , so the common peak is at 4 , 6 , but if I dont know where the common peak occur , how can I find the data that occur at the same X coordinate .
clear
pure_brain = readmatrix('Pure Brain Spectra.csv');
[pks,locsBr] = findpeaks(pure_brain(:,2));
LvBrain = pure_brain(locsBr,2)>0; % Set Threshold = 1E+4
xBrain = 1:size(pure_brain,1);
YBrain = pure_brain(locsBr(LvBrain),2);
YBrain = YBrain .* 100/max(YBrain);
[pks_min,pks_max] = bounds(pks); % Minimum & Maximum Values Of pks
figure
pure_Liver = readmatrix('Pure Liver Spectra.csv');
[pks,locsLiv] = findpeaks(pure_Liver(:,2));
LvLiver = pure_Liver(locsLiv,2)>0; % Set Threshold = 1E+4
xLiver = 1:size(pure_Liver,1);
YLiver = pure_Liver(locsLiv(LvLiver),2);
YLiver = YLiver .* 100/max(YLiver);
plot(xBrain(locsLiv(LvBrain)), YBrain, '.r')
hold on
plot(xLiver(locsLiv(LvLiver)), YLiver, '.b')
hold off
grid
% To find common peaks considering the threshold of 1E+4:
lB = locsBr(LvBrain);
lL = locsLiv(LvLiver);
s = max(length(lB), length(lL));
locsLivNew = [lL; false(s-length(lL),1)];
locsBrNew = [lB; false(s-length(lB),1)];
common = locsLivNew == locsBrNew; % Find the common location of peaks
  5 件のコメント
Image Analyst
Image Analyst 2021 年 4 月 8 日
If you're up for it, Mathieu, just define one as a variable and continue on with the solution
windowWidth = 15; % whatever....
% Now code to call findpeaks() and find out which peaks
% are within windowWidth of peaks in other signal....
Then he can change the number to whatever he wants.
Mathieu NOE
Mathieu NOE 2021 年 4 月 8 日
thank you for the tip, but I'd like to see first the OP clarify his needs - have to work a bit for my company sometimes !

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

回答 (1 件)

Image Analyst
Image Analyst 2021 年 4 月 8 日
Try experimenting around with ismember().

カテゴリ

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