%% Flat Minima Regions
% Specify a method for indicating consecutive minima values.
%
% Compute the local minima of data that contains consecutive minima values.  Indicate the minimum of each flat region based on the first occurrence of that value.

x = 0:0.1:5;
A = max(-0.75, sin(pi*x));
TF1 = islocalmin(A, 'FlatSelection', 'first');
plot(x,A,x(TF1),A(TF1),'r*')

%
% Indicate the minimum of each flat region with all occurrences of that value.

TF2 = islocalmin(A, 'FlatSelection', 'all');
plot(x,A,x(TF2),A(TF2),'r*')

% Copyright 2012 The MathWorks, Inc.