Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sampled2continuous

Signal reconstruction


Description

Analog signal reconstruction from discrete samples.

Usage

sampled2continuous(xn, fs, t)

Arguments

xn

the sampled input signal, specified as a vector

fs

sampling frequency in Hz used in collecting x, specified as a positive scalar value. Default: 1

t

time points at which data is to be reconstructed, specified as a vector relative to x[0] (not real time).

Details

Given a discrete signal x[n] sampled with a frequency of fs Hz, this function reconstruct the original analog signal x(t) at time points t. The function can be used, for instance, to calculate sampling rate effects on aliasing.

Value

Reconstructed signal x(t), returned as a vector.

Author(s)

Muthiah Annamalai, muthiah.annamalai@uta.edu. Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

Examples

# 'analog' signal: 3 Hz cosine
t <- seq(0, 1, length.out = 100)
xt <- cos(3 * 2 * pi * t)
plot(t, xt, type = "l", xlab = "", ylab = "", ylim = c(-1, 1.2))

# 'sample' it at 4 Hz to simulate aliasing
fs <- 4
n <- ceiling(length(t) / fs)
xn <- xt[seq(ceiling(n / 2), length(t), n)]
s4 <- sampled2continuous(xn, fs, t)
lines(t, s4, col = "red")

# 'sample' it > 6 Hz to avoid aliasing
fs <- 7
n <- ceiling(length(t) / fs)
xn <- xt[seq(ceiling(n / 2), length(t), n)]
s7 <- sampled2continuous(xn, fs, t)
lines(t, s7, col = "green")
legend("topright", legend = c("original", "aliased", "non-aliased"),
  lty = 1, col = c("black", "red", "green"))

gsignal

Signal Processing

v0.3-1
GPL-3
Authors
Geert van Boxtel [aut, cre] (Maintainer), Tom Short [aut] (Author of 'signal' package), Paul Kienzle [aut] (Majority of the original sources), Ben Abbott [ctb], Juan Aguado [ctb], Muthiah Annamalai [ctb], Leonardo Araujo [ctb], William Asquith [ctb], David Bateman [ctb], David Billinghurst [ctb], Juan Pablo Carbajal [ctb], André Carezia [ctb], Vincent Cautaerts [ctb], Eric Chassande-Mottin [ctb], Luca Citi [ctb], Dave Cogdell [ctb], Carlo de Falco [ctb], Carne Draug [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], R.G.H Eschauzier [ctb], Andrew Fitting [ctb], Alan J. Greenberger [ctb], Mike Gross [ctb], Daniel Gunyan [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Jake Janovetz [ctb], Alexander Klein [ctb], Peter V. Lanspeary [ctb], Bill Lash [ctb], Friedrich Leissh [ctb], Laurent S. Mazet [ctb], Mike Miller [ctb], Petr Mikulik [ctb], Paolo Neis [ctb], Georgios Ouzounis [ctb], Sylvain Pelissier [ctb], Francesco Potortì [ctb], Charles Praplan [ctb], Lukas F. Reichlin [ctb], Tony Richardson [ctb], Asbjorn Sabo [ctb], Thomas Sailer [ctb], Rolf Schirmacher [ctb], Rolf Schirmacher [ctb], Ivan Selesnick [ctb], Julius O. Smith III [ctb], Peter L. Soendergaard [ctb], Quentin Spencer [ctb], Doug Stewart [ctb], P. Sudeepam [ctb], Stefan van der Walt [ctb], Andreas Weber [ctb], P. Sudeepam [ctb], Andreas Weingessel [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.