title: finding peak start and end points
body: <p>I have a series of peaks <a href="https://i.imgur.com/PMyoHhq.jpg" rel="nofollow noreferrer">Peaks image</a>, I used matlab findpeaks to find the peak points .</p>
  
  <p>I need to find peak widths and the peak start and end points ? I have started</p>
  
  <p>with this code , but it is not giving me the right width calculation :</p>
  
  <pre><code>% If the peak is at index 150
  % Scan to the right.
  for k = 151:length(signal)
     if signal(k) &lt; signal(k-1)
      % Signal is starting to fall.
      rightIndex = k-1;
      break;
    end
  end
  % Scan to the left.
  for k = 149: -1 : 1
     if signal(k) &lt; signal(k+1)
       % Signal is starting to fall.
       leftIndex = k+1;
       break;
    end
  end
  peakWidth = rightIndex - leftIndex;
  </code></pre>