# Signal with two periods: 2 and 7
t <- seq(0, 20, length.out = 400)
X <- sin(2 * pi * t / 2) + 0.6 * sin(2 * pi * t / 7)
fd <- fdata(matrix(X, nrow = 1), argvals = t)
# Detect multiple periods
result <- detect.periods(fd, max_periods = 3)
print(result$periods) # Should find approximately 2 and 7
print(result$n_periods) # Should be 2
Run the code above in your browser using DataLab