title: Unexpected behaviour of function findpeaks in MATLAB's Signal Processing Toolbox
body: <p>Edit: Actually this is not unexpected behaviour, but I still need a solution. 
  <code>findpeaks compares each element of data to its neighboring values.</code></p>
  
  <p>I have data which contains peaks which I detect with the function <a href="http://www.mathworks.com/help/toolbox/signal/findpeaks.html" rel="nofollow noreferrer">findpeaks</a> from the Signal Processing Toolbox. Sometimes the function seems not to detect the peaks properly, when I have the same value twice next to each other. This occurs very rarly in my data, but here is a sample to illustrate my problem:</p>
  
  <pre><code>&gt;&gt; values
  
  values =
  
     -0.0324
     -0.0371
     -0.0393
     -0.0387
     -0.0331
     -0.0280
     -0.0216
     -0.0134
     -0.0011
      0.0098
      0.0217
      0.0352
      0.0467
      0.0548
      0.0639
      0.0740
      0.0813
      0.0858                  &lt;-- here should be another peak
      0.0858                  &lt;--
      0.0812
      0.0719
      0.0600
      0.0473
      0.0353
      0.0239
      0.0151
      0.0083
      0.0034
     -0.0001
     -0.0025
     -0.0043
     -0.0057
     -0.0048
     -0.0038
     -0.0026
      0.0007
      0.0043
      0.0062
      0.0083
      0.0106
      0.0111
      0.0116
      0.0102
      0.0089
      0.0057
      0.0025
     -0.0025
     -0.0056
  </code></pre>
  
  <p>Now the findpeaks function only finds one peak:</p>
  
  <pre><code>&gt;&gt; [pks loc] = findpeaks(values)
  
  pks =
  
      0.0116
  
  
  loc =
  
      42
  </code></pre>
  
  <p>If I plot the data, it becomes obvious that findpeaks misses one of the peaks at the location <code>18/19</code> because they both have the value <code>0.08579</code>.</p>
  
  <p><img src="https://i.stack.imgur.com/Djt53.png" alt="alt text"></p>
  
  <p>What is the best way to find those missing peaks? </p>