You are here : matlabSignal Processingcummax

cummax() - Signal Processing

M = cummax(A) returns
the cumulative maximum elements of A. By default, cummax(A) operates
along the first array dimension whose size does not equal 1.If A is a vector, then cummax(A) returns
a vector of the same size containing the cumulative maxima of A.If A is a matrix, then cummax(A) returns
a matrix of the same size containing the cumulative maxima in each
column of A.If A is a multidimensional array,
then cummax(A) returns an array of the same size
containing the cumulative maxima along the first array dimension of A whose
size does not equal 1.exampleM = cummax(A,dim) returns
the cumulative maxima along the dimension dim.
For example, if A is a matrix, then cummax(A,2) returns
the cumulative maxima along the rows of A.exampleM = cummax(___,direction) optionally
specifies the direction using any of the previous syntaxes. You must
specify A and, optionally, can specify dim.
For instance, cummax(A,2,'reverse') returns the
cumulative maxima of A by working from end to beginning
of the second dimension of A.


Syntax

M = cummax(A) exampleM = cummax(A,dim) exampleM = cummax(___,direction) example


Example

Cumulative Maximum Values in VectorOpen This Example
Find the cumulative maxima of a 1-by-10 vector of random integers.v = randi(10,1,10)

v =

     9    10     2    10     7     1     3     6    10    10

M = cummax(v)

M =

     9    10    10    10    10    10    10    10    10    10

Cumulative Maximum Values in Matrix ColumnsOpen This Example
Find the cumulative maxima of the columns of a 3-by-3 matrix.A = [3 5 2; 1 6 3; 7 8 1]

A =

     3     5     2
     1     6     3
     7     8     1

M = cummax(A)

M =

     3     5     2
     3     6     3
     7     8     3

Cumulative Maximum Values in Matrix RowsOpen This Example
Find the cumulative maxima of the rows of a 3-by-3 matrix.A = [3 5 2; 1 6 3; 7 8 1]

A =

     3     5     2
     1     6     3
     7     8     1

M = cummax(A,2)

M =

     3     5     5
     1     6     6
     7     8     8

Cumulative Maximum Array Values in Reverse DirectionOpen This Example
Calculate the cumulative maxima in the third dimension of a 2-by-2-by-3 array. Specify direction as 'reverse' to work from the end of the third dimension to the beginning.A = cat(3,[1 2; 3 4],[9 10; 11 12],[5 6; 7 8])

A(:,:,1) =

     1     2
     3     4


A(:,:,2) =

     9    10
    11    12


A(:,:,3) =

     5     6
     7     8

M = cummax(A,3,'reverse')

M(:,:,1) =

     9    10
    11    12


M(:,:,2) =

     9    10
    11    12


M(:,:,3) =

     5     6
     7     8


Output / Return Value


Limitations


Alternatives / See Also


Reference