0

I have a noisy periodic signal in Matlab that I've extracted peaks from with the help of [peak loc]=findpeaks(signal). However unrealistic outliers are also inside the peak array. I set min- and max-values for peak and so get a shorter peak array. Now I would love to mark this shorter subset of original peak into the original plot(loc,peak), whereat I'd get an error, since loc has kept its original length.

My questions:

  • Is there a way in the fashion of a container.map or something similar that allows to adapt loc to peak with consistence of the loc-peak assignments?

    • How can I alternatively plot the shortened peak array onto the original signal plot?

Thanks a lot!

Aliakbar Ahmadi
  • 366
  • 3
  • 14

1 Answers1

2

I think you can solve your problem with following code:

[peak,loc] = findpeaks(signal);
max_thr = 2;
min_thr = 1e-5;    
mask = peak>min_thr&peak<max_thr;
plot(loc(mask),peak(mask))

Is this what you want ?

toygan kılıç
  • 422
  • 4
  • 16