Code covered by the BSD License  

Highlights from
Peaks picking

Be the first to rate this file! 22 Downloads (last 30 days) File Size: 2.5 KB File ID: #27811
image thumbnail

Peaks picking

by Christos Saragiotis

 

01 Jun 2010

Finds peaks or troughs in a vector o 2-D matrix.

| Watch this File

File Information
Description

PICKPEAKS is similar to MATLAB's FINDPEAKS; it returns local peaks and their indices for the input X. The main differences are that PICKPEAKS
- is faster (much faster for large vectors),
- allows X to be a 2D matrix (not just a vector) and the user can specify across which dimension to look for peaks.
- picks either peaks or troughs.
- does not provide the FINDPEAKS option ‘THRESHOLD’.
- does not provide the FINDPEAKS’ options: ‘MINPEAKHEIGHT’, ‘NPEAKS’, ‘SORTSTR’. Those can be achieved easily by manipulating the output. E.g. if Vo, Io are the output of PICKPEAKS, the following will yield the same result as setting ‘MINPEAKHEIGHT’ to 0.5:
   i = find(Vo<0.5);
   Vo(i) = [];
   Io(i) = [];

The syntax is
   [Vo,Io] = PICKPEAKS(X,npts,dim,mode);

Examples of usage are:
[Vo,Io] = PICKPEAKS(X);
[Vo,Io] = PICKPEAKS(X,[],[],’troughs’);
[Vo,Io] = PICKPEAKS(X,10,[],’troughs’); % require at least 10 samples distance between troughs.
[Vo,Io] = PICKPEAKS(X,[],2); % search for peaks across rows

The screenshot was generated by
   x = randn(200,1);
   tic, [val,ind] = pickpeaks(x,10); toc
   tic, [pks,loc] = findpeaks(x,'minpeakdistance',10); toc
   figure, plot(x), hold all, plot(ind,val,'ro', loc,pks,'k+', 'MarkerSize',10), legend('x','pickpeaks','findpeaks')

Notice another difference between FINDPEAKS and PICKPEAKS: FINDPEAKS does not qualify some peaks (e.g. 3 peaks around sample 50) because there are other peaks in their vicinity, which did not qualify either. PICKPEAKS will pick those as well.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Local Peaks

MATLAB release MATLAB 7.9 (2009b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
data exploration Christos Saragiotis 01 Jun 2010 10:55:24
statistics Christos Saragiotis 01 Jun 2010 10:55:24
general tools Christos Saragiotis 01 Jun 2010 10:55:24
maxima Christos Saragiotis 02 Jun 2010 01:20:30
local Christos Saragiotis 02 Jun 2010 01:20:30
minima Christos Saragiotis 02 Jun 2010 01:20:30
peaks Christos Saragiotis 02 Jun 2010 01:20:30
troughs Christos Saragiotis 02 Jun 2010 01:20:30

Contact us at files@mathworks.com