Matching two plots to find the number of same peaks in it.

2 ビュー (過去 30 日間)
akash Pattyil
akash Pattyil 2022 年 6 月 12 日
回答済み: VINAYAK LUHA 2023 年 9 月 15 日
Can you please help to find the coding to relate two plots and find number of same peaks in both the plots.
  2 件のコメント
Image Analyst
Image Analyst 2022 年 6 月 12 日
The answer is "Yes" or at least "probably".
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
In the meantime, check out my attached demos to fit a specified number of Gaussians to some data.
If you have the Signal Processing Toolbox, also check out findpeaks.
Jeffrey Clark
Jeffrey Clark 2022 年 6 月 12 日
Please check that one of your classmates hasn't already posted the same question. You could then add your name via a comment on that question or by following it: match peaks from plot - (mathworks.com)

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

回答 (1 件)

VINAYAK LUHA
VINAYAK LUHA 2023 年 9 月 15 日
Hi Akash,
It is my understanding that you wish to find the number of same peaks in two plots. This answer assumes that by same peak, you mean same x coordinates of the peaks.
You can use the “findpeak” function in “Signal Processing Toolbox” as shown below –
%Generate and plotting data
y1 = [0,2,0,5,10,10,10,6,15,9];
y2 = [18,6,9,4,7,6,0,3,5,4];
plot(y1,"color","red");
hold on;
plot(y2,"color","blue");
%Finding x and y coordinates of peaks
[pk1,lc1] = findpeaks(y1,1:10);
[pk2,lc2]= findpeaks(y2,1:10);
plot(lc1,pk1,'o','MarkerSize',8,MarkerFaceColor='red');
plot(lc2,pk2,'o','MarkerSize',8,MarkerFaceColor="blue");
%Plotting peaks
commonPeakXs = intersect(lc1,lc2);
commonPeakYs = pk1(ismember(lc1, commonPeakXs));
plot(commonPeakXs,commonPeakYs,'o','MarkerSize',12,MarkerEdgeColor="k");
hold off
Next, you can use the “length” function to find the number of common peaks. Here’s a link to the documentation of “findpeaks” function for your reference https://in.mathworks.com/help/signal/ref/findpeaks.html
Hope this helps!
Regards,
Vinayak Luha

カテゴリ

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