function [X,A,C,T] = getSeatData(fileNameBase,showplot)
%GETSEATDATA Load Filtered Seat Vibration Data
% GETSEATDATA reads the MS Excel formatted version of Seat Vibration Data
% specified in FILENAMEBASE, filters the data according to the filter defined
% by myLPFilter. FILENAMEBASE is the basic file name witout numbers (i.e.
% seatvib_config1 will load in all data for files named
% seavib_configXX.xls where XX is the numeric extention.
%
% Syntax:
% [X,A,C,T] = getSeatData(fileName) returns the filtered signals
% displacement and acceleration into X and A, repectively. C is
% controller force signal. T is the time.
%
% See Also: xlsread, filter, myLPFilter, plotSeatVib
%% Search the Directory for Files
% fileNameBase is the search string
D = dir([fileNameBase,'*']);
%% Start Looping for each File
for i = 1:length(D)
fileName = D(i).name;
%% Load in the numeric data in Filename
num = xlsread(fileName);
%% Parse the Numeric Data into appropriate variables
% Data is in the form: Time, displacement, acceleration, control_Force.
% Text Labels are in the first row, so numeric data starts in row 2.
T(:,i) = num(:,1);
Xraw(:,i) = num(:,2);
Araw(:,i) = num(:,3);
C(:,i) = num(:,4);
%% Filter Displacement and Acceleration
% Use the myLPFilter definition to filter the data.
X(:,i) = filter(myLPFilter,Xraw(:,i));
A(:,i) = filter(myLPFilter,Araw(:,i));
%% Plot the Raw and Filtered Data
% Use the plotSeatVib function to show the data.
if sum( showplot == i )
plotSeatData(T(:,i),Xraw(:,i),X(:,i),Araw(:,i),A(:,i),C(:,i),fileName);
end
%% Stop Looping
end