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

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

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

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

% Copyright 2012 The MathWorks, Inc.