Question
I have a 2 column array. It represents an exponential rise/fall of voltage and the time for each datapoint. In the voltage, I want to locate the data in a window between the first time the voltage exceeds 0.2*Vpeak up to when it falls below 0.4*Vpeak. The values before and after the window are then to be replaced with zeros.
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 23, 2026
First, you can use the "findpeaks" function to find all the local peaks in your data:
>> [pks, locs] = findpeaks(voltage);
Then, from all the peaks, determine the global peak:
>> [vPeak, iPeak] = max(pks); >> locPeak = locs(iPeak);
Finally, use the "find" function to find the indices of when your signal reaches 0.2*Vpeak and drops to 0.4*Vpeak of its peak:
>> idx_start = find(voltage(1:locPeak) < 0.2*vPeak, 1, 'last'); >> idx_end = locPeak + find(voltage(locPeak:end) < 0.4*vPeak, 1, 'first');
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 →