Question
How would I find the first twelve local maximum (peak) values for y and the corresponding times (t) using a script?
Expert Answer
Prashant Kumar
PhD Expert
Answered Aug 25, 2026
If you don’t have the Signal Processing Toolbox, and since you have a clean, noise-free signal, this works:
x = linspace(0,20,250); % Create Data y = exp(-0.25*x) .* sin(2.5*pi*x); % Create Data dy = gradient(x,y); % Derivative: dy/dx zx = dy.*circshift(dy, [0 -1]); % Zero-Crossings Of Derivative pkix = find(zx<0); % Zero-Crossing Indices pkix = pkix(y(pkix)>0); % Indices Of Peaks xpks = x(pkix(1:12)); % X-Coordinates Of First 12 Peaks ypks = y(pkix(1:12)); % Y-Coordinates Of First 12 Peaks figure(1) plot(x,y) hold on plot(xpks,ypks,'^r') hold off

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 →