Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
library(wavelets)
load_data <- function(filename, row) {
data = read.csv(filename, header=FALSE, sep=",")
return(data[[row]])
}
wavelet_transform <- function(data) {
Wavelet_out = matrix(0, 1, 8)
Wave_results = dwt(data, "filter" = "haar")
Wavelet_out[1, 1] = slot(Wave_results, "V")[[1]][1]
Wavelet_out[1, 2] = slot(Wave_results, "V")[[2]][1]
Wavelet_out[1, 3] = slot(Wave_results, "V")[[3]][1]
Wavelet_out[1, 4] = slot(Wave_results, "V")[[4]][1]
Wavelet_out[1, 5] = slot(Wave_results, "V")[[5]][1]
Wavelet_out[1, 6] = slot(Wave_results, "V")[[6]][1]
Wavelet_out[1, 7] = slot(Wave_results, "V")[[7]][1]
Wavelet_out[1, 8] = slot(Wave_results, "V")[[8]][1]
return(Wavelet_out)
}
setwd("/Users/geri/Work/wavelet_test/src")
raw_data = load_data("../data/wavelet_test.csv", 2)
res = wavelet_transform(raw_data)
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.