% Transform mean tide to tide free

clc
%Input file
[day, time, east, north, up, type, sat, ...
    p1, p2, p3, p4, p5, p6, p7, p8] = loadPosFile('../vstup/2018_24_G-enu.txt');

%Output file
out = fopen('../vstup/2018_24_G-tide.txt', 'w')

%Mean tide 2 tide free transformation function
[eastCor, northCor, upCor] = meanTide2TideFree(east, north, up);

for i = 1 : length(day)
    if east(i) == NaN
        fprintf(out,'%s %s NaN NaN NaN %s %s %s %s %s %s %s %s %s %s\r\n', ...
            day{i},...
            time{i},...            
            eastC(i),...
            north(i),...
            up(i),...
            type{i}, ...
            sat{i},...
            p1{i}, ...
            p2{i}, ...
            p3{i}, ...
            p4{i}, ...
            p5{i}, ...
            p6{i}, ...
            p7{i}, ...
            p8{i});
        
    else    
        
  fprintf(out,'%s %s %0.4f %0.4f %0.4f %s %s %s %s %s %s %s %s %s %s\r\n', ...
            day{i},...
            time{i},...            
            eastCor(i),...
            northCor(i),...
            upCor(i),...
            type{i}, ...
            sat{i},...
            p1{i}, ...
            p2{i}, ...
            p3{i}, ...
            p4{i}, ...
            p5{i}, ...
            p6{i}, ...
            p7{i}, ...
            p8{i});
    end
    
end

fclose(out);
clear
disp('Done');