Description Usage Arguments Examples
Find peaks (maxima) in a time series. This function is modified from
pracma::findpeaks
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
x |
Numeric vector. |
IsDiff |
If want to find extreme values, |
nups |
minimum number of increasing steps before a peak is reached |
ndowns |
minimum number of decreasing steps after the peak |
zero |
can be |
peakpat |
define a peak as a regular pattern, such as the default
pattern |
minpeakheight |
The minimum (absolute) height a peak has to have to be recognized as such |
minpeakdistance |
The minimum distance (in indices) peaks have to have
to be counted. If the distance of two maximum extreme value less than
|
y_min |
Threshold is defined as the difference of peak value with
trough value. There are two threshold (left and right). The minimum threshold
should be greater than |
y_max |
Similar as |
npeaks |
the number of peaks to return. If |
sortstr |
Boolean, Should the peaks be returned sorted in decreasing oreder of their maximum value? |
IsPlot |
Boolean. |
1 2 3 4 5 6 7 8 9 10 11 12 | x <- seq(0, 1, len = 1024)
pos <- c(0.1, 0.13, 0.15, 0.23, 0.25, 0.40, 0.44, 0.65, 0.76, 0.78, 0.81)
hgt <- c(4, 5, 3, 4, 5, 4.2, 2.1, 4.3, 3.1, 5.1, 4.2)
wdt <- c(0.005, 0.005, 0.006, 0.01, 0.01, 0.03, 0.01, 0.01, 0.005, 0.008, 0.005)
pSignal <- numeric(length(x))
for (i in seq(along=pos)) {
pSignal <- pSignal + hgt[i]/(1 + abs((x - pos[i])/wdt[i]))^4
}
plot(pSignal, type="l", col="navy"); grid()
x <- findpeaks(pSignal, npeaks=3, y_min=4, sortstr=TRUE)
points(val~pos, x$X, pch=20, col="maroon")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.