%% b_FilterDemo.m
% ME370 Data Filtering
clear all; close all; clc

%% Load Data & Plot
load('ForcePlateData')

%% Filter data
figure(1); hold on
plot(t,dataN_L)
title('vGRF Data, Left')
xlabel('Time [s]')
ylabel('[N]')

filt_L = smoothdata(dataN_L);
filt_R = smoothdata(dataN_R);

%Plot filtered data
plot(t, filt_L,'k')
legend('Raw','Filtered')
xlim([0 1.2])% show only one gait cycle

%% NOTES on filtering with the default settings
% The default lets Matlab set moving window width
% Filtering nicely removes noise during "flight" phase when force = 0
% Filtering blunts the peaks and valleys
% Significanlty reduces peak height
% Increases valley minima
% Alters time of "Initial Contact" and "Foot Off" 
% Obliterates the small peak during the first ramp up
% Filter perforemance can be improved by setting filter parameters or by
% using differnt types of filters.
