From 8ffe5c85b13ff631b7b4276781b9e3180b3d4c23 Mon Sep 17 00:00:00 2001 From: Max Nyberg Carlsson <max.nyberg_carlsson@control.lth.se> Date: Tue, 25 Oct 2022 16:15:21 +0200 Subject: [PATCH] Initial work on frequency method --- Project.toml | 6 ++++++ frequency_power.jl | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 Project.toml create mode 100644 frequency_power.jl diff --git a/Project.toml b/Project.toml new file mode 100644 index 0000000..1777ccd --- /dev/null +++ b/Project.toml @@ -0,0 +1,6 @@ +[deps] +DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2" +DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" +FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" +FourierTools = "b18b359b-aebc-45ac-a139-9c0ccbb2871e" +Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" diff --git a/frequency_power.jl b/frequency_power.jl new file mode 100644 index 0000000..9282b7f --- /dev/null +++ b/frequency_power.jl @@ -0,0 +1,16 @@ +using Pkg; Pkg.activate("."); +using FFTW, DSP, Plots, DelimitedFiles + +function plot_spectogram(s, n=div(length(s),8), noverlap=div(n,2)) + spec = spectrogram(s, n, noverlap) + heatmap(spec.time, spec.freq, spec.power) +end + +function read_data(dataname, gyro=false) + if !gyro + return readdlm("data/$(dataname)_acc.txt", Float64) + else + return (readdlm("data/$(dataname)_acc.txt", Float64), + readdlm("data/$(dataname)_gyr.txt", Float64)) + end +end -- GitLab