Question
I know this topic has been discussed before to some extent, but I can't seem to figure out a way to do the following. I am finding peaks in my kernel distribution function which is returned in terms of PDF and X, where PDF vs. X is plotted. To find the peaks I do the following: [Peaks, Locs] = findpeaks(PDF) ; %Find Y value of the peaks X_peakVal = X(Locs) ; %Find X value of the peaks However, I would like to reject some values for some peaks that lie below a threshold: [Peaks, Locs] = findpeaks(PDF) ; %Find Y value of the peaks Peaks(Peaks < 0.01*max(Peaks)) = [] ; %Reject Y value of peaks below this threshold X_peakVal = X(Locs) ; %Find X value of the peaks The above code does not reject the corresponding indices noted as Locs, such as the corresponding X_peakVal (or X values corresponding to the Y peaks) are also rejected. What is a way to exclude the corresponding X values to the rejected Y?
Expert Answer
John Michell
PhD Expert
Answered Aug 24, 2026
You also need to remove those points from loc
smallPeakIndexes = Peaks < 0.01*max(Peaks); Peaks(smallPeakIndexes) = [] ; %Reject Y value of peaks below this threshold Locs(smallPeakIndexes) = [] ; %Reject Y value of peaks below this threshold
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related matlab Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →