schtrig | R Documentation |
Multisignal Schmitt trigger with levels.
schtrig(x, lvl, st = NULL)
x |
input data, specified as a numeric vector or matrix. In case of a vector it represents a single signal; in case of a matrix each column is a signal. |
lvl |
threshold levels against which |
st |
trigger state, specified as a vector of length |
The trigger works compares each column in x
to the levels in
lvl
, when the value is higher than max(lvl)
, the output
v
is high (i.e. 1); when the value is below min(lvl)
the output
is low (i.e. 0); and when the value is between the two levels the output
retains its value.
a list
containing the following variables:
vector or matrix of 0's and 1's, according to whether x
is
above or below lvl
, or the value of x
if indeterminate
ranges in which the output is high, so the indexes
rng[1,i]:rng[2,i]
point to the i-th segment of 1s in v
. See
clustersegment
for a detailed explanation.
trigger state, returned as a vector with a length of the number
of columns in x
.
Juan Pablo Carbajal, carbajal@ifi.uzh.ch.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.
clustersegment
t <- seq(0, 1, length.out = 100)
x <- sin(2 * pi * 2 * t) + sin(2 * pi * 5 * t) %*% matrix(c(0.8, 0.3), 1, 2)
lvl <- c(0.8, 0.25)
trig <- schtrig (x, lvl)
op <- par(mfrow = c(2, 1))
plot(t, x[, 1], type = "l", xlab = "", ylab = "")
abline(h = lvl, col = "blue")
lines(t, trig$v[, 1], col = "red", lwd = 2)
plot(t, x[, 2], type = "l", xlab = "", ylab = "")
abline(h = lvl, col = "blue")
lines(t, trig$v[, 2], col = "red", lwd = 2)
par(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.