# NOT RUN {
#Create a vector of time that represent times where data are sampled.
Fs = 100; #sampling frequency in Hz
T = 1/Fs; #sampling period
L = 1000; #length of time vector
t = (0:(L-1))*T; #time vector
#Form a signal (time series) that contains two frequencies:
#1. 10 Hz with amplitude of 1
#2. 25 Hz with amplitude of 2
S <- 1*sin(2*pi*10*t) + 2*sin(2*pi*25*t);
results <- MakePowerSpectralDensity(Fs, S)
frequencies <- results[[1]]
PSD <- results[[2]]
#dev.new()
plot(frequencies, PSD, type = "l")
bins <- list(
c(9, 11),
c(24,26),
c(9,26),
c(30,40)
)
integration.results <- PSDIntegrationPerFreqBin(Fs, S, bins)
message.captured <- list()
for(i in 1:length(integration.results)){
message <- paste("Area in bin ", integration.results[[i]][[1]], " is ",
integration.results[[i]][[2]])
message.captured[[i]] <- message
}
# }
Run the code above in your browser using DataLab