Skip to content
Snippets Groups Projects
Commit b156b47e authored by Wouda, Frank (UT-EEMCS)'s avatar Wouda, Frank (UT-EEMCS)
Browse files

Made the filter cut off frequency a setting, double checked if results align...

Made the filter cut off frequency a setting, double checked if results align between this version and the original.
parent 023aca77
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@
% output:
% dataStruct - containing calculated FPA.
function dataStruct = calculateSteps(dataStruct, trialName)
function dataStruct = calculateSteps(dataStruct, trialName, fCutOff)
% Get the trial data.
data = dataStruct.(trialName);
......@@ -17,12 +17,12 @@ calibrationFields = fieldnames(dataStruct.calibration);
% By default take the first calibration trial.
calibration = dataStruct.calibration.(calibrationFields{1});
% cut-off frequency of the filter.
fCutoff = 2;
% Store the cut-off frequency.
data.fCutOff = fCutOff;
% 2nd order low-pass butterworth filter to get the relevant motion data.
% Implement as filtfilt due to no realtime constraints.
[Bf, Af] = butter(2, (2 * fCutoff / data.fs));
[Bf, Af] = butter(2, (2 * data.fCutOff / data.fs));
data.filtAcc = filtfilt(Bf, Af, data.acc);
data.filtGyr = filtfilt(Bf, Af, data.gyr);
......
......@@ -15,12 +15,9 @@
function data = initOrien(data)
% cut-off frequency of the filter.
data.fCutoff = 2;
% 2nd order low-pass butterworth filter to get the relevant motion data.
% Implement as filtfilt due to no realtime constraints.
[Bf, Af] = butter(2, (2 * data.fCutoff / data.fs));
[Bf, Af] = butter(2, (2 * data.fCutOff / data.fs));
data.filtAcc = filtfilt(Bf, Af, data.acc);
data.filtGyr = filtfilt(Bf, Af, data.gyr);
......
......@@ -4,7 +4,7 @@
clear all; close all; clc
% Run the settings file.
settingsFile
settingsFile;
% Allocate space for storing the data.
dataStruct = struct();
......@@ -19,7 +19,7 @@ for i = 3:length(subjectFolders)
dataStruct.(subjectFolders(i).name) = struct();
dataStruct.(subjectFolders(i).name).calibration = getCalibration( ...
join([subjectFolders(i).folder '\' subjectFolders(i).name '\' calibrationFolder],''));
join([subjectFolders(i).folder '\' subjectFolders(i).name '\' calibrationFolder],''), fCutOff);
for j = 1:length(trialFiles)
currentPath = [trialFiles(j).folder '\' trialFiles(j).name];
......@@ -31,7 +31,7 @@ for i = 3:length(subjectFolders)
% calculate all values for each step.
dataStruct.(subjectFolders(i).name) = ...
math.calculateSteps(dataStruct.(subjectFolders(i).name), trialName);
math.calculateSteps(dataStruct.(subjectFolders(i).name), trialName, fCutOff);
end
end
......
%% This function reads in data from Movella DOT csv files of the calibration folder.
% filePath - full path to where calibration files are stored.
function dataStruct = getCalibration(filePath)
function dataStruct = getCalibration(filePath, fCutOff)
% Only select the files that are relevant.
calibDir = dir(filePath);
......@@ -26,6 +26,9 @@ function dataStruct = getCalibration(filePath)
dataStruct.(trialName).calibration = struct();
end
% cut-off frequency of the filter.
dataStruct.(trialName).fCutOff = fCutOff;
% Determine the calibration orientation.
dataStruct.(trialName) = math.initOrien(dataStruct.(trialName));
......
......@@ -15,4 +15,7 @@ dirFlags = [allFiles.isdir];
subjectFolders = allFiles(dirFlags);
% gravity constant is defined.
gravity = 9.81;
\ No newline at end of file
gravity = 9.81;
% filter cut off frequency.
fCutOff = 10;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment