# Create some functional data
t <- seq(0, 1, length.out = 100)
X <- matrix(sin(2 * pi * t), nrow = 1)
fd <- fdata(X, argvals = t)
# Project to basis and reconstruct
coefs <- fdata2basis(fd, nbasis = 15, type = "fourier")
fd_recon <- basis2fdata(coefs, argvals = t, type = "fourier")
Run the code above in your browser using DataLab