No BSD License  

Highlights from
peaks

2.83333

2.8 | 12 ratings Rate this file 9 Downloads (last 30 days) File Size: 278 Bytes File ID: #7694
image thumbnail

peaks

by Nagi Hatoum

 

19 May 2005 (Updated 10 Jun 2005)

Find the peaks and troughs in a vector.

| Watch this File

File Information
Description

A simple rugged script that finds the peaks and troughs of a signal, vector, or data points. The results are returned in two index vectors p and t.
Notice: Might drop end points or give two point where adjacent data have the same value.
Returns column-wise peak and through index vectors

MATLAB release MATLAB 5.2 (R10)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (15)
24 May 2005 Yuri Kotliarov

1. Function PEAKS exists in R14.
2. vector has to be a column.
3. Will those commands do the same thing?
Xmax = find(diff(diff(X)<0)==1)+1;
Xmin = find(diff(diff(X)>0)==1)+1;

25 May 2005 Sergei Koptenko

There are at least two entries in Matlab File Exchange- "Local min, max, nearest neighbour" from 2003-03-21 and "Find Peak Value" from 2003-12-10 that do exactly the same as this function.

01 Jun 2005 James J. Cai

Xmax = find(diff(X,2)<0)==1)+1;
Xmin = find(diff(X,2)>0)==1)+1;

09 Jun 2005 John Walters

Thanks, I don't have the latest Matlab version

14 Sep 2005 Gao Jianqiang

In this article,can the author give me a example of the use of the peak.m.
Why can't I produce the same figure above?
Waiting for other friends help me?!
Thanks!

05 Dec 2005 Duane Hanselman

No usable help text provided. It is unclear what the function does without testing it. Poor programming practices.

06 Feb 2006 ravs sam

great code, could use comments!

03 May 2006 J W

Is it possible to add a script/function to measure the absolute vertical distance between peaks and corresponding troughs?
Overall the function worked well identifying peaks and their horizontal location for me.

09 May 2006 hi ya

this is rubbish, just use Diff() and don't bother downloading

25 May 2006 L J

Works well, exactly what I was looking for. Thanks

15 Sep 2006 Ai Ve

Check out EXTREME.M on this site, it is a great improvement, also for 2D!

31 Oct 2007 Dimitri Shvorob

Outdated - see other comments.

10 Jul 2008 Viprali Bhatkar

It is really helpful for finding peaks and troughs in any signal. Thank you!!

21 May 2009 Nikola Stanchev

Excellent! The code is very helpful. Simple and genius.

26 May 2012 UMP

Nagi Hatoum:
Can you give me an example of peak.m.How I can adapt peak.m into my file? This is the command:

%imported data from excel sheet
x=xlsread('Data_Test.xls','A4:A65536');
y=xlsread('Data_Test.xls','B4:B65536');
%signal plot
figure
plot(x,y);
title('Ripple current');
xlabel('Time');
ylabel('Voltage');
grid on

I really appreciate your help and also others response.

Please login to add a comment or rating.
Updates
10 Jun 2005

accepts column or row vector.

Tag Activity for this File
Tag Applied By Date/Time
peak Nagi Hatoum 22 Oct 2008 07:49:02
through Nagi Hatoum 22 Oct 2008 07:49:02
maximum Nagi Hatoum 22 Oct 2008 07:49:02
minimum Nagi Hatoum 22 Oct 2008 07:49:02
point Nagi Hatoum 22 Oct 2008 07:49:02

Contact us at files@mathworks.com