Learn R Programming

MassSpecWavelet (version 1.38.0)

localMaximum: Identify local maximum within a slide window.

Description

Find local maximum by transform the vector as matrix, then get the the maximum of each column. This operation is performed twice with vecctor shifted half of the winSize.

Usage

localMaximum(x, winSize = 5)

Arguments

x
a vector represents a signal profile
winSize
the slide window size, 5 by default.

Value

Return a vector with the same length of the input x. The position of local maximum is set as 1, 0 else where.

Details

Instead of find the local maximum by a slide window, which slide all possible positions, we find local maximum by transform the vector as matrix, then get the the maximum of each column. This operation is performed twice with vecctor shifted half of the winSize. The main purpose of this is to increase the efficiency of the algorithm.

See Also

getLocalMaximumCWT

Examples

Run this code
x <- rnorm(200)
lmax <- localMaximum(x, 5)
maxInd <- which(lmax > 0)
plot(x, type='l')
points(maxInd, x[maxInd], col='red')

Run the code above in your browser using DataLab