function dispDuringScan = getInitDisp(scanLength,logFileTLD,expNum)
%dispDuringScan = getInitDisp(scanLength, logFileTLD, expNum)
%==========================================================================
% Find the displacement reading at the start of a scan, the last point in
% the previous displacement log. Assume constant displacement during the
% scan. From comparing the last entry of the log file before and the first
% entry of the log file after, this seems to be a good assumption.
%
% --- INPUT ---
% scanLength - int, total number of entries in the load/time logs for the
%              scan
% logFileTLD - string, top level directory for the log files to find the
%              current location of the crosshead
% expNum - int, current experiment number
%
% --- OUTPUT ---
% dispDuringScan - vec, displacement during the scan, of length scanLength
%
% -------------------------------------------------------------------------
% History - Orion L. Kafka
% 12-11-2017 - written
%
%==========================================================================

% Get the initial crosshead location
logFile = fullfile(logFileTLD,['Exp',padWithZeros(3,expNum),'_loading_history'],'load_history.log');
logData = importdata(logFile,' ');
initDisp = str2double(logData.textdata{3,2});
% assume constant displacement during scanning
dispDuringScan = ones(scanLength,1).*initDisp;