MATLAB Answers

How to filter data that detects peaks or irregularities?

3 views (last 30 days)
Mariana on 18 Jan 2020
Commented: Image Analyst on 18 Jan 2020
I am trying to build a code that detects these peaks. This graph represents the change in position in time. What I am doing is read the distance timestep by timestep.
I compare the new distance minus the old distance, if this values difference is higher than 5 meters I assume theres a peak. The problem is that each dataset have undefined number of peaks and undefined number of green datasets to save.
How can I solve this?


Sign in to comment.

Answers (1)

Star Strider
Star Strider on 18 Jan 2020
Several functions already exist to do that, among which are findpeaks, islocalmax, ischange, and others.


Show 4 older comments
Mariana on 18 Jan 2020
Unfortunately, I dont have the Toolbox.
for i=1:50
if i~= 50
j = i + 1;
diff = abs(xnew - xold);
if diff > 5
stop(i)= i;
peaks = find (stop~= 0);
num = lenght(peaks) %fnumber of peaks found
for i=1:num
toDelete = x.distance((change(i)-100): change(i))
x(toDelete,:)= []
If I get this:
peaks = [15568 , 15702, 15778]
I want to delete the peaks from 100 points before to the peak
delete from 15468 to 15568 , 15602 to 15702 , 15678 to 15778
I am not sure how to make a for loop that could delete them if the number of peaks is variable.
Star Strider
Star Strider on 18 Jan 2020
Do you have R2017b or later?
Note: No data to analyse.
Image Analyst
Image Analyst on 18 Jan 2020
Mariana, make it easy for people to help you, not hard. Attach your data in a .mat file with the paper clip icon after you read this link.

Sign in to comment.

Sign in to answer this question.

Translated by