Matching two plots to find the number of same peaks in it.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Can you please help to find the coding to relate two plots and find number of same peaks in both the plots.
2 commentaires
Image Analyst
le 12 Juin 2022
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.
Jeffrey Clark
le 12 Juin 2022
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)
Réponses (1)
VINAYAK LUHA
le 15 Sep 2023
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
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!