schtrig {gsignal} | R Documentation |
Schmitt Trigger
Description
Multisignal Schmitt trigger with levels.
Usage
schtrig(x, lvl, st = NULL)
Arguments
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 |
Details
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.
Value
a list
containing the following variables:
- v
vector or matrix of 0's and 1's, according to whether
x
is above or belowlvl
, or the value ofx
if indeterminate- rng
ranges in which the output is high, so the indexes
rng[1,i]:rng[2,i]
point to the i-th segment of 1s inv
. Seeclustersegment
for a detailed explanation.- st
trigger state, returned as a vector with a length of the number of columns in
x
.
Author(s)
Juan Pablo Carbajal, carbajal@ifi.uzh.ch.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.
See Also
Examples
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)