No BSD License  

Highlights from
extrema.m, extrema2.m

4.6

4.6 | 10 ratings Rate this file 390 Downloads (last 30 days) File Size: 51.59 KB File ID: #12275
image thumbnail

extrema.m, extrema2.m

by Carlos Adrian Vargas Aguilera

 

14 Sep 2006 (Updated 11 Apr 2007)

Search all extrema points of a time series or a surface with/without NaN's.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

Search all the maxima and minima points (peaks) in a time series (vector) or a surface (matrix), via columns, rows and crossing diagonals, ignoring NaN's elements.

USAGE:

[zmax,imax,zmin,imin]= extrema2(peaks);

where zmax (zmin) are the maxima (minima) elements and imax (imin) their linear index (check IND2SUB).

They come with the examples on the screenshot.

These are the same files as EXTREME.M and EXTREME2.M, but updated.

Acknowledgements
This submission has inspired the following:
MinimaMaxima3D, Extrema
MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (19)
15 Sep 2006 Sasha Trevizo

The author sure had a headache after he finished this, so, thanks for avoid it to me! It works really good!

14 Nov 2006 cloves souza

e muito legal

22 Nov 2006 JaeKyu Suhr

This is excellent, but when i use extreme2.m
There is an error related to a variable "indx".
Therefore, I put a little bit of code in "extreme.m" like this

% NaN's:
inan = find(isnan(x));
if ~isempty(inan)
 indx = 1:Nt;
 indx(inan) = [];
 x(inan) = [];
 Nt = length(x);
%%----added code
else
    indx = 1:Nt;
%%%%%%%%%%%%%%%%
end

22 Nov 2006 Carlos Adrián Vargas Aguilera

Thanks JaeKyu Suhr!, new file with bug fixed in about 1 day...

15 Jan 2007 Johnny Job

Well done.

01 Mar 2007 Jacob Eisenstein

thanks, very helpful.

06 Apr 2007 Dimitri Shvorob

It might be helpful to briefly explain the exact definition of 'extreme points'.

09 Apr 2007 Carlos Adrián Vargas Aguilera

You are so right Dimitri! I've made a terrible translation from spanish, I meant "extrema points"... Ouch! I need to change even the name!

12 Jul 2008 angeles sierra

kiero agregar un linck a mi fotolog
 pero no se como aserle

14 Nov 2008 Yin Wang

Excellent work, this is exactly what I need.

28 May 2009 joe saucer

hey guys.. is their anyway for this program to just give me the biggest maxes? my plot has many, many small peaks.. also, can you store these as variables?

26 Mar 2010 Sanjeev

Excellent work

15 Feb 2011 Rick Towler  
15 Feb 2011 Rick Towler

Nice work.

29 Apr 2011 Rafael

Perfect for finds maximun and minimuns in a surface! Great Job

25 Aug 2011 Aslak Grinsted

Nice. There is also the built-in function findpeaks from the signal processing toolbox:

http://www.mathworks.se/help/toolbox/signal/findpeaks.html

30 Oct 2011 Onkar Singh Gujral  
12 Dec 2011 Thomas

much better than findpeaks for my data thanks so much!

14 Feb 2012 Anusha

Can someone help me on how to adapt this to detect maxima and minima points on an object edge?

Please login to add a comment or rating.
Updates
13 Nov 2006

English translation from spanish. Little changes on the submit and screenshot.

17 Nov 2006

Now accepting NaN's.

22 Nov 2006

Fix bug in indx (by JaeKyu Suhr)

11 Apr 2007

Change the name to EXTREMA and EXTREMA2. Added definition. Little changes on the submit.

Tag Activity for this File
Tag Applied By Date/Time
matrices Carlos Adrian Vargas Aguilera 22 Oct 2008 08:39:25
extrema points Carlos Adrian Vargas Aguilera 22 Oct 2008 08:39:25
maxima points Carlos Adrian Vargas Aguilera 22 Oct 2008 08:39:25
minima points Carlos Adrian Vargas Aguilera 22 Oct 2008 08:39:25
peaks Carlos Adrian Vargas Aguilera 22 Oct 2008 08:39:25
peak Carlos Adrian Vargas Aguilera 22 Oct 2008 08:39:25
max Carlos Adrian Vargas Aguilera 22 Oct 2008 08:39:25
peaks Rishab Sethi 02 Nov 2008 18:24:30
potw Cristina McIntire 07 Nov 2008 13:22:00
pick of the week Jiro Doke 11 Feb 2011 20:15:41
extrema points Emerry JAO 23 May 2011 08:06:01
peaks Emerry JAO 23 May 2011 08:06:06
potw Slawomir 08 Nov 2011 10:12:07
extrema points Yonatan Ridelman 16 Jan 2012 03:16:39

Contact us at files@mathworks.com