Home > wafo > onedim > findextrema.m

# findextrema

## PURPOSE

Finds indices to minima and maxima of data

## SYNOPSIS

ind = findextrema(x)

## DESCRIPTION

``` FINDEXTREMA Finds indices to minima and maxima of data

CALL: ind = findextrema(x);

x  = vector with sampled values.

ind = indices to minima and maxima in the original sequence x.

Example
t = linspace(0,7*pi,250); x = sin(t);
ind = findextrema(x)
plot(t,x,'.',t(ind),x(ind),'r.')

## CROSS-REFERENCE INFORMATION

This function calls:
 findcross Finds indices to level v up and downcrossings of a vector diff Difference and approximate derivative.
This function is called by:
 dat2tp Extracts turning points from data,

## SOURCE CODE

```01 function ind = findextrema(x)
02 %FINDEXTREMA Finds indices to minima and maxima of data
03 %
04 %  CALL: ind = findextrema(x);
05 %
06 %        x  = vector with sampled values.
07 %
08 %    ind = indices to minima and maxima in the original sequence x.
09 %
10 % Example
11 %  t = linspace(0,7*pi,250); x = sin(t);
12 %  ind = findextrema(x)
13 %  plot(t,x,'.',t(ind),x(ind),'r.')
14 %
16
17
18 % Tested on: Matlab 5.3, 5.2 5.1
19
20 % History:
21 % by pab April2004
22
23
24 ind = findcross(diff(x),0)+1;```

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003