### Highlights from extrema.m, extrema2.m

4.61538

4.6 | 15 ratings Rate this file 327 Downloads (last 30 days) File Size: 51.6 KB File ID: #12275

# extrema.m, extrema2.m

14 Sep 2006 (Updated )

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

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
MATLAB release MATLAB 7 (R14)
11 Mar 2014

thank you
this saves me a day of coding...

27 Jun 2013

Hello, does anybody know how to replicate those detected extrema points onto a grayscale image.

Thank You

10 Apr 2013

Do you have an option to put the sensitivity of the peaks? to only get the higher ones....

21 Mar 2013
29 Jun 2012

Hi all i have to calculate the LUV color components any one can help me...

30 Apr 2012

Hola Carlos!
I am having some issues though... I am using your function inside a script which uses fminsearch also... and getting the following error message:

Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can

Error in extrema

Error while evaluating uicontrol Callback

Help! How do I solve this problem!
Gracias y muchos saludos!

22 Mar 2012

[Gmax,imax,Gmin,imin] = extrema2(G);
hold on
plot3(T(imax),f(imax),Gmax,'bo')
for i = 1:length(Gmax)
text(x(imax(i)),y(imax(i)),zmax(i),[' ' num2str(zmax(i))])
end
hold off}
My problem is the T,f,G are of different sizes and an error comes up saying '??? Index exceeds matrix dimensions.' any suggestions please help

22 Mar 2012

I have a problem while using it for an array can u explain an example as u did it for a vector please, I am a begginer with this stuff

04 Mar 2012
04 Mar 2012
14 Feb 2012

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

12 Dec 2011

much better than findpeaks for my data thanks so much!

30 Oct 2011
25 Aug 2011

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

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

29 Apr 2011

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

15 Feb 2011

Nice work.

15 Feb 2011
26 Mar 2010

Excellent work

28 May 2009

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?

14 Nov 2008

Excellent work, this is exactly what I need.

12 Jul 2008

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

09 Apr 2007

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!

06 Apr 2007

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

01 Mar 2007

15 Jan 2007

Well done.

22 Nov 2006

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

22 Nov 2006

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);
else
indx = 1:Nt;
%%%%%%%%%%%%%%%%
end

14 Nov 2006

e muito legal

15 Sep 2006

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

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)