%   Script: combineNav
%   Author: Daniel O'Hara
%   Date: 12/6/2015
%   Description: Script to combine raw navigation data from local directory.

load('codePaths.mat')
folderPath = path_cnav; %local directory.
navForm = 'Nav_*2015*_Data.mat'; %File name header.

navFiles = ls([folderPath,'\',navForm]);
navDataTitles = {'Year','Day','Hour','Minute','Second','Serial Date','Time Diff (s)','Latitude DD','Longitude DD'};
    % Formatted data fields.

sNF = size(navFiles);
newNav = [];

for i = 1:sNF(1,1) %Combine local directory raw navigation data. 
    load([folderPath,'\',navFiles(i,:)])
    newNav = [newNav;navData];
end

% Create serial date data.
allNavData = newNav(:,1:5);
seri = datenum([newNav(:,1),convertYD2MD(newNav(1,1),newNav(:,2)),newNav(:,3:5)]);
dif = [0;diff(seri,1,1)].*24;
allNavData = [allNavData,seri,dif,newNav(:,6:end)];
    
% Save results.
save([folderPath,'\Nav_All_Data.mat'],'allNavData','navDataTitles','-v7')