How to use findpeaks for a matrix of size A

I
Ikramullah · Feb 11, 2021 · 1.8K views
Question
I have a  matrix of 4*8. I would like to find out the no of peaks in each row,with a condition that peak value-minimum value >1000.How should i do it.I have tried following code, but not working. i have tried [peaks]=findpeaks(A),but not working.  
Expert Answer
Profile picture of John Williams
John Williams PhD Expert
Answered Nov 20, 2025
The findpeaks function will work, but you have to cycle through the rows:
 
 
M = randi(99, 4, 8);
for k1 = 1:size(M,1)
    [pks,loc] = findpeaks(M(k1,:));
    P{k1} = [pks; loc];
end

The cell array accounts for different numbers of peaks and locations in each row.

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

Get a Free Consultation or a Sample Assignment Review!