%% e_FloorDemo.m 
% ME370 Data Analysis: offset data zero, remove noise
clear all; close all; clc

%% Load Data & Plot
load('ForcePlateData')
load('flight')
load('floorMean')
figure(1); hold on
plot(t,dataN_L)
plot(flight(:,1),flight(:,2),'r.')
legend('Raw', 'Noise')
title('vGRF Data, Left, Noise Identified')
xlabel('Time [s]')
ylabel('[N]')

%% Eliminate noise in floor
cleanGRF_L = dataN_L;
%TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
% TASK: Replace any values greater than the floor maximum with 
% the floor Mean (floorMean)
cleanGRF_L(cleanGRF_L < floorMax) = 
figure(2)
plot(t,cleanGRF_L)
title('vGRF Data, Left, Clean Floor')
xlabel('Time [s]')
ylabel('[N]')

%% Set the plot x and y limits
xlim([0 t(end)]);
ylim([-100,1200]);

%% Shift data so that average of flight phase is zero
% Assumes the force plate sensors were not zeroed before data collection

figure(3)
%TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
% TASK: Compensate for systematic error by subtracting the 
% floor mean (floorMean) from the data (cleanGRF_L)
shiftGRF_L = 
plot(t,shiftGRF_L)
title('vGRF Data, Left, Shifted')
xlabel('Time [s]')
ylabel('[N]')
save('shiftGRF_L', 'shiftGRF_L')

%% Set the plot x and y limits
xlim([0 t(end)]);
ylim([-100,1200]);

%% NOTES 